test_XML.cmake 1.82 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#First check if we can compile with XML2
try_compile(FLEUR_USE_XML ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/cmake/tests/test_XML.f90
LINK_LIBRARIES ${FLEUR_LIBRARIES}
            )

if (NOT FLEUR_USE_XML)
      find_package(LibXml2)
      set(CMAKE_C_FLAGS "-I${LIBXML2_INCLUDE_DIR}")
      set(TEST_LIBRARIES ${FLEUR_LIBRARIES} ${LIBXML2_LIBRARIES})
 
try_compile(FLEUR_USE_XML ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/cmake/tests/test_XML.f90
	    LINK_LIBRARIES ${TEST_LIBRARIES}
            )
       if (FLEUR_USE_XML)
              set(FLEUR_LIBRARIES ${LIBXML2_LIBRARIES} ${FLEUR_LIBRARIES})
	      set(FLEUR_MPI_LIBRARIES ${LIBXML2_LIBRARIES} ${FLEUR_MPI_LIBRARIES})
       endif()
endif()       

Daniel Wortmann's avatar
Daniel Wortmann committed
20 21 22 23 24 25 26 27 28 29 30 31 32 33
#Try to simply add -lxml2
if (NOT FLEUR_USE_XML)
      set(TEST_LIBRARIES ${FLEUR_LIBRARIES} -lxml2)

try_compile(FLEUR_USE_XML ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/cmake/tests/test_XML.f90
            LINK_LIBRARIES ${TEST_LIBRARIES}
            )
       if (FLEUR_USE_XML)
              set(FLEUR_LIBRARIES -lxml2 ${FLEUR_LIBRARIES})
              set(FLEUR_MPI_LIBRARIES -lxml2 ${FLEUR_MPI_LIBRARIES})
       endif()
endif()


34 35 36 37
message("XML Library found for linking:${FLEUR_USE_XML}")

if (FLEUR_USE_XML)
   try_compile(FLEUR_USE_XML ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/cmake/tests/test_XML.c
Daniel Wortmann's avatar
Daniel Wortmann committed
38
   CMAKE_FLAGS "-DCMAKE_C_LINK_EXECUTABLE='echo no linking'" LINK_LIBRARIES "-lxml2")
39 40 41 42
   if (NOT FLEUR_USE_XML)
      find_package(LibXml2)
      set(CMAKE_C_FLAGS "-I${LIBXML2_INCLUDE_DIR}")
      try_compile(FLEUR_USE_XML ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/cmake/tests/test_XML.c
Daniel Wortmann's avatar
Daniel Wortmann committed
43
      LINK_LIBRARIES ${LIBXML2_LIBRARIES})
44 45 46 47 48
   endif()
endif()

message("XML Library found for C:${FLEUR_USE_XML}")

49 50 51 52

if (FLEUR_USE_XML)
   set(FLEUR_DEFINITIONS ${FLEUR_DEFINITIONS} "CPP_XML") 
   set(FLEUR_MPI_DEFINITIONS ${FLEUR_MPI_DEFINITIONS} "CPP_XML")
53
endif()