X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=cmake%2FCREAMacro_FindAndUseLibraries.cmake;h=d60b46335c289a02b948c1ab750045fb928a3336;hb=5139c575b9d3d4a58427b17db6a37ca26e3470d0;hp=e55bce933cf307d7b1feba74a00f842b4742f5aa;hpb=46013e93c62ef74d9cb5864f9b9a216f75e1e8a7;p=crea.git diff --git a/cmake/CREAMacro_FindAndUseLibraries.cmake b/cmake/CREAMacro_FindAndUseLibraries.cmake index e55bce9..d60b463 100644 --- a/cmake/CREAMacro_FindAndUseLibraries.cmake +++ b/cmake/CREAMacro_FindAndUseLibraries.cmake @@ -2,6 +2,13 @@ MACRO(CREA_FIND_AND_USE_LIBRARIES) +IF(INCLUDE_CTEST) + include(CTest) +ENDIF(INCLUDE_CTEST) + + +set(USE_DEBUG_LIB "" CACHE BOOL "Use Debug Libraries" ) + #----------------------------------------------------------------------------- # If one can invoke this macro then crea has already been found !! # However if one whishes to link against crea and crea was built @@ -19,6 +26,7 @@ ENDIF(USE_CREA) #----------------------------------------------------------------------------- + IF(USE_QT4) IF(NOT QT_FOUND) @@ -33,13 +41,18 @@ IF(USE_QT4) INCLUDE(${QT_USE_FILE}) CREA_DEFINE( USE_QT ) - # SET(QT_LIBRARIES - # ${QT_LIBRARIES} - # ) - # MARK_AS_ADVANCED(Qt4_DIR) + ENDIF(QT_FOUND) ENDIF(NOT QT_FOUND) ENDIF(USE_QT4) + + +#JFGA Pruebas WT + +MESSAGE ( "======================================= SET CMAKE USE_WT JFGA CREAMacro_FindAndUseLibraries.cmake") +SET(USE_WT ON) + + #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- @@ -78,7 +91,10 @@ IF(USE_KWWIDGETS) ENDIF(USE_KWWIDGETS) #----------------------------------------------------------------------------- - +# --- W A R N I N G : +# Always let ITK *BEFORE* GDCM +# It allows to use 'system installed gdcm' instead of 'itk embedded gdcm' +# #----------------------------------------------------------------------------- IF(USE_ITK) @@ -95,9 +111,15 @@ IF(USE_ITK) INCLUDE(${ITK_USE_FILE}) CREA_DEFINE( USE_ITK ) CREA_DEFINE( _USE_ITK_ ) - SET(ITK_LIBRARIES - ITKCommon ITKIO ITKBasicFilters ITKAlgorithms - ) + If (${ITK_VERSION_MAJOR} MATCHES "4") + MESSAGE ( STATUS "* Version = ${ITK_VERSION_MAJOR}.${ITK_VERSION_MINOR}.${ITK_VERSION_PATCH}") + SET(ITK_LIBRARIES + ${ITK_LIBRARIES}) + MESSAGE ( STATUS "${ITK_LIBRARIES}") + ELSEIF() + SET(ITK_LIBRARIES + ITKCommon ITKIO ITKBasicFilters ITKAlgorithms) + ENDIF() MARK_AS_ADVANCED(ITK_DIR) ELSE(ITK_FOUND) message(FATAL_ERROR "ITK_DIR not found") @@ -108,6 +130,7 @@ ENDIF(USE_ITK) #----------------------------------------------------------------------------- + IF(USE_GDCM) IF (USE_GDCM2) MESSAGE(ERROR "CANNOT USE BOTH gdcm AND gdcm2 !") @@ -120,13 +143,13 @@ IF(USE_GDCM) IF(GDCM_FOUND) INCLUDE(${GDCM_USE_FILE}) CREA_DEFINE( USE_GDCM ) - + MESSAGE ( STATUS "=======================================") MESSAGE ( STATUS "Looking for GDCM... found") MESSAGE ( STATUS "* Dir = ${GDCM_DIR}") MESSAGE ( STATUS "* Version = ${GDCM_MAJOR_VERSION}.${GDCM_MINOR_VERSION}.${GDCM_BUILD_VERSION}") MESSAGE ( STATUS "* Namespace = ${GDCM_NAME_SPACE}") - + # Test that GDCM_NAME_SPACE is **NOT** "gdcm" or will conflict with # embedded gdcm in ITK and will result in hard seg faults ! IF(USE_ITK) @@ -134,13 +157,13 @@ IF(USE_GDCM) MESSAGE(FATAL_ERROR "GDCM_NAME_SPACE value is 'gdcm' which conflicts with ITK embededd gdcm namespace : rebuild gdcm with another GDCM_NAME_SPACE value") ENDIF (GDCM_NAME_SPACE STREQUAL "gdcm") ENDIF(USE_ITK) - + MARK_AS_ADVANCED(GDCM_DIR) - + SET(GDCM_LIBRARIES ${GDCM_LIBRARIES} ) - + # TODO : Test that GDCM was built with option "vtkgdcm" IF(USE_GDCM_VTK) IF(USE_VTK) @@ -150,27 +173,33 @@ IF(USE_GDCM) ) ENDIF(USE_VTK) ENDIF(USE_GDCM_VTK) - + + ELSE(GDCM_FOUND) + MESSAGE(FATAL_ERROR "GDCM not found....") ENDIF(GDCM_FOUND) + ENDIF(NOT GDCM_FOUND) ENDIF(USE_GDCM) #----------------------------------------------------------------------------- -#----------------------------------------------------------------------------- IF(USE_GDCM2) - IF(NOT GDCM_FOUND) + IF (USE_GDCM) + MESSAGE(ERROR "CANNOT USE BOTH gdcm AND gdcm2 !") + ENDIF (USE_GDCM) + +# IF(NOT USE_ITK) # JPR : ITK vs GDCM (avoid cmake break) # Search GDCM2 - FIND_PACKAGE(GDCM) - # If gdcm found - IF(GDCM_FOUND) - INCLUDE(${GDCM_USE_FILE}) - + + FIND_PACKAGE(GDCM REQUIRED) + INCLUDE(${GDCM_USE_FILE}) + IF(NOT ${GDCM_MAJOR_VERSION} EQUAL 2) MESSAGE(FATAL_ERROR "gdcm version 2 needed. found ${GDCM_MAJOR_VERSION}.${GDCM_MINOR_VERSION}.${GDCM_BUILD_VERSION}. Set GDCM_DIR to the gdcm version 2 directory") ENDIF(NOT ${GDCM_MAJOR_VERSION} EQUAL 2) CREA_DEFINE( USE_GDCM2 ) + MARK_AS_ADVANCED(GDCM_DIR) CREA_DEFINE_WITH_VAL( GDCM_NAME_SPACE gdcm ) MESSAGE ( STATUS "=======================================") @@ -181,39 +210,64 @@ IF(USE_GDCM2) # Test that GDCM_NAME_SPACE is **NOT** "gdcm" or will conflict with # embedded gdcm in ITK and will result in hard seg faults ! - IF(USE_ITK) - IF (GDCM_NAME_SPACE STREQUAL "gdcm") - MESSAGE(FATAL_ERROR "GDCM_NAME_SPACE value is 'gdcm' which conflicts with ITK embededd gdcm namespace : rebuild gdcm with another GDCM_NAME_SPACE value") - ENDIF (GDCM_NAME_SPACE STREQUAL "gdcm") - ENDIF(USE_ITK) - - MARK_AS_ADVANCED(GDCM_DIR) - - SET(GDCM_LIBRARIES + INCLUDE_DIRECTORIES(${GDCM_INCLUDE_DIRS}) + LINK_DIRECTORIES( ${GDCM_LIBRARY_DIRS}) + + SET(GDCM2_LIBRARIES ${GDCM_LIBRARIES} ) - - # TODO : Test that GDCM was built with option "vtkgdcm" + IF(USE_GDCM_VTK) IF(USE_VTK) - SET(GDCM_LIBRARIES - ${GDCM_LIBRARIES} - vtkgdcm - ) + IF(WIN32) + SET(GDCM_LIBRARIES + ${GDCM_LIBRARIES} + vtkgdcm + gdcmIOD + gdcmMSFF + gdcmexpat + gdcmCommon + gdcmMEXD + gdcmexpat + gdcmDSED + gdcmDICT + gdcmjpeg8 + gdcmjpeg12 + gdcmjpeg16 + socketxx + gdcmopenjpeg + gdcmcharls + ) + ELSE(WIN32) + SET(GDCM_LIBRARIES + ${GDCM_LIBRARIES} + vtkgdcm + gdcmIOD + ) + ENDIF(WIN32) + ENDIF(USE_VTK) ENDIF(USE_GDCM_VTK) - - ENDIF(GDCM_FOUND) - ENDIF(NOT GDCM_FOUND) + # ENDIF(NOT USE_ITK) # JPR : ITK vs GDCM (avoid cmake break) + ENDIF(USE_GDCM2) #----------------------------------------------------------------------------- +#----------------------------------------------------------------------------- + +#-------------------- JFGA --- +IF(USE_WT) + MESSAGE ( "======================================= JFGA ------------USE WT CREAMacro_FindAndUseLibraries.cmake") + INCLUDE(${CREA_CMAKE_DIR}/CREAMacro_FindAndUseWt.cmake) + CREA_FINDANDUSEWT() +ENDIF(USE_WT) + #----------------------------------------------------------------------------- IF(USE_WXWIDGETS) IF(NOT wxWidgets_FOUND) INCLUDE(${CREA_CMAKE_DIR}/CREAMacro_FindAndUseWxWidgets.cmake) - CREA_FIND_WXWIDGETS() + CREA_FIND_WXWIDGETS(${USE_DEBUG_LIB}) CREA_USE_WXWIDGETS() ENDIF(NOT wxWidgets_FOUND) ENDIF(USE_WXWIDGETS) @@ -237,11 +291,14 @@ ENDIF(USE_DOXYGEN) #----------------------------------------------------------------------------- -IF(USE_LATEX) +IF(USE_LATEX) IF (NOT LATEX_COMPILER) FIND_PACKAGE(LATEX REQUIRED) MESSAGE ( STATUS "=======================================") MESSAGE(STATUS "Looking for latex... - found ${LATEX_COMPILER}") + IF (NOT LATEX_FOUND) + MESSAGE(FATAL_ERROR "LATEX_COMPILER NOT FOUND. Example:latex (MacOS:/opt/local/bin/latex)") + ENDIF (NOT LATEX_FOUND) ENDIF (NOT LATEX_COMPILER) ENDIF(USE_LATEX) @@ -262,66 +319,122 @@ IF(USE_TTH) ENDIF(NOT TTH_EXECUTABLE) ENDIF(USE_TTH) #----------------------------------------------------------------------------- - #----------------------------------------------------------------------------- IF(USE_BOOST) IF(NOT Boost_FOUND) - FIND_PACKAGE(Boost REQUIRED) - IF(Boost_FOUND) + add_definitions( -DBOOST_ALL_NO_LIB ) + add_definitions( -DBOOST_ALL_DYN_LINK ) + FIND_PACKAGE(Boost COMPONENTS filesystem system signals date_time thread regex program_options REQUIRED) + IF(Boost_FOUND) + ADD_DEFINITIONS(-DBOOST_FILESYSTEM_VERSION=3) MESSAGE ( STATUS "=======================================") MESSAGE ( STATUS "Looking for boost C++ library... - found in ${Boost_INCLUDE_DIR}") INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) - LINK_DIRECTORIES( ${Boost_LIBRARY_DIRS} ) - - CREA_DEFINE( USE_BOOST ) + LINK_DIRECTORIES( ${Boost_LIBRARY_DIRS}) IF(WIN32) - - LINK_DIRECTORIES( ${Boost_INCLUDE_DIRS}/stage/lib) #JCP 01/10/2009 - #LINK_DIRECTORIES( ${Boost_LIBRARY_DIRS}) - #MESSAGE ("EED " ${Boost_LIBRARY_DIRS}) - #libboost_signals-vc71-mt-1_37 - #libboost_filesystem-vc71-mt-1_37 - #boost_date_time-vc71-mt-1_37 - - #message("creamacro find and use lib = ${Boost_SIGNALS_LIBRARY}") + CREA_DEFINE( USE_BOOST ) + ADD_DEFINITIONS(-DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED) SET(BOOST_LIBRARIES - boost_signals-vc90-mt-1_40 - boost_filesystem-vc90-mt-1_40 - boost_date_time-vc90-mt-1_40 - - #what about boost_thread? JPR - ) + ${Boost_LIBRARIES} + ) + +# FCY with cmake boost, it's useless. +# But if it is not working, uncomment +# +# IF(USE_DEBUG_LIB) +# SET(BOOST_LIBRARIES +# boost_signals-vc90-mt-gd-1_40 +# boost_filesystem-vc90-mt-gd-1_40 +# boost_date_time-vc90-mt-gd-1_40 +# #what about boost_thread? JPR +# ) +# ELSE(NOT USE_DEBUG_LIB) +# SET(BOOST_LIBRARIES +# boost_signals-vc90-mt-1_40 +# boost_filesystem-vc90-mt-1_40 +# boost_date_time-vc90-mt-1_40 +# ) +# ENDIF(USE_DEBUG_LIB) ENDIF(WIN32) IF(NOT WIN32) - IF(APPLE) - SET(BOOST_LIBRARIES - boost_signals - boost_filesystem - boost_date_time - boost_program_options - boost_regex - boost_thread - ) - ELSE(NOT APPLE) + SET(BOOST_LIBRARIES - boost_signals-mt - boost_filesystem-mt - boost_date_time-mt - boost_system-mt - boost_program_options-mt - boost_regex-mt - boost_thread-mt + + ${Boost_LIBRARIES} +#EED 10 Fev 2014 +#EED boost_system-mt +#EED boost_thread-mt +#EED boost_program_options-mt + +#EED 03 mars 2011 +#EED boost_signals-mt +#EED boost_filesystem-mt +#EED boost_date_time-mt +#EED boost_system-mt +#EED boost_program_options-mt +#EED boost_regex-mt +#EED boost_thread-mt + ) - ENDIF(APPLE) ENDIF(NOT WIN32) - - MARK_AS_ADVANCED(Boost_INCLUDE_DIR) + + MARK_AS_ADVANCED(Boost_INCLUDE_DIR) + MARK_AS_ADVANCED(Boost_LIBRARY_DIRS) + ELSE(Boost_FOUND) - MESSAGE(FATAL_ERROR "boost C++ library not found - Set Boost_INCLUDE_DIR to the directory containing boost headers") + MESSAGE( STATUS "boost C++ library not found - Set Boost_INCLUDE_DIR to the directory containing boost headers") ENDIF(Boost_FOUND) ENDIF(NOT Boost_FOUND) + + ENDIF(USE_BOOST) -#----------------------------------------------------------------------------- +#----------------------------------------------------------- + +IF(USE_XERCES) + + # FIND xerces + IF(WIN32) + + SET(XERCES_LIB_DIR $ENV{XERCES_DIR}) + + IF(NOT XERCES_LIB_DIR) + MESSAGE(FATAL_ERROR "XERCES_DIR not found") + ELSE(NOT XERCES_LIB_DIR) + + INCLUDE_DIRECTORIES( ${XERCES_LIB_DIR}/include ) + LINK_DIRECTORIES( ${XERCES_LIB_DIR}/lib ) + + ENDIF(NOT XERCES_LIB_DIR) + + IF(USE_DEBUG_LIB) + set(XERCES_LIBRARIES xerces-c_3D) + ELSE(USE_DEBUG_LIB) + set(XERCES_LIBRARIES xerces-c_3) + ENDIF(USE_DEBUG_LIB) + + MARK_AS_ADVANCED(XERCES_LIB_DIR) + ENDIF(WIN32) + + + IF(UNIX) + IF(APPLE) + SET(XERCES_LIBRARIES xerces-c ) + INCLUDE_DIRECTORIES( /opt/local/include ) + LINK_DIRECTORIES( /opt/local/lib ) +#JCP 10/01/11 + ELSE(NOT APPLE) + SET(XERCES_LIBRARIES xerces-c ) + INCLUDE_DIRECTORIES( /usr/local/include ) + LINK_DIRECTORIES( /usr/local/lib /usr/lib) + #FIND_PACKAGE(Xerces) + # Use if found + #IF(Xerces_FOUND) + # INCLUDE_DIRECTORIES( ${XERCES_INCLUDE_DIR} ) + #ENDIF(Xerces_FOUND) + ENDIF(APPLE) + ENDIF(UNIX) + +ENDIF(USE_XERCES) ENDMACRO(CREA_FIND_AND_USE_LIBRARIES)