test_XML.cmake 1.39 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()       

20 21 22 23
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
24
   CMAKE_FLAGS "-DCMAKE_C_LINK_EXECUTABLE='echo no linking'" LINK_LIBRARIES "-lxml2")
25 26 27 28
   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
29
      LINK_LIBRARIES ${LIBXML2_LIBRARIES})
30 31 32 33 34
   endif()
endif()

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

35 36 37 38

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