X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=CMakeLists.txt;h=b583e9bfa70ead1c6c61da743d679c1c4a2e2145;hb=5f2f63726d61c93ece8e85fe9fc7c5fa8093bf61;hp=4546410e822684ec5ef25324df3b02e33fa52c50;hpb=dbb25a7b734864a11ba84a5089f7b5e647099f0a;p=gdcm.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 4546410e..b583e9bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,11 @@ PROJECT(GDCM) CMAKE_MINIMUM_REQUIRED(VERSION 2.0) +# okay in fact you need at least cmake 2.0.4 to get swig working properly #----------------------------------------------------------------------------- # GDCM version number, usefull for packaging and doxygen doc: SET(GDCM_MAJOR_VERSION 1) -SET(GDCM_MINOR_VERSION 0) +SET(GDCM_MINOR_VERSION 2) SET(GDCM_BUILD_VERSION 0) SET(GDCM_VERSION "${GDCM_MAJOR_VERSION}.${GDCM_MINOR_VERSION}.${GDCM_BUILD_VERSION}") @@ -15,6 +16,12 @@ SET(GDCM_DATA_DIR "/share/gdcm/" CACHE INTERNAL "Install location for data (relative to prefix).") MARK_AS_ADVANCED(GDCM_DATA_DIR) +#----------------------------------------------------------------------------- +# Provide compatibility options. +OPTION(GDCM_LEGACY_REMOVE "Remove all legacy code completely." OFF) +OPTION(GDCM_LEGACY_SILENT "Silence all legacy code messages." OFF) +MARK_AS_ADVANCED(GDCM_LEGACY_REMOVE GDCM_LEGACY_SILENT) + #----------------------------------------------------------------------------- # Build shared lib by default OPTION(GDCM_BUILD_SHARED_LIBS "Build GDCM with shared libraries." ON) @@ -33,23 +40,27 @@ MARK_AS_ADVANCED(LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH) EXPORT_LIBRARY_DEPENDENCIES(${GDCM_BINARY_DIR}/GDCMLibraryDepends.cmake) +# Save the compiler settings so another project can import them. +INCLUDE(${CMAKE_ROOT}/Modules/CMakeExportBuildSettings.cmake) +CMAKE_EXPORT_BUILD_SETTINGS(${GDCM_BINARY_DIR}/GDCMBuildSettings.cmake) +#INSTALL_FILES(/lib/gdcm .cmake GDCMBuildSettings) + # For GDCM from build tree: SET(GDCM_USE_FILE ${GDCM_SOURCE_DIR}/GDCMUse.cmake) SET(GDCM_INCLUDE_DIRS - ${GDCM_BINARY_DIR}/src + ${GDCM_BINARY_DIR}/ #for gdcmConfigure.h + ${GDCM_SOURCE_DIR}/src #for main gdcm include ) SET(GDCM_LIBRARY_DIRS ${LIBRARY_OUTPUT_PATH}) SET(GDCM_LIBRARY_DEPENDS_FILE ${GDCM_BINARY_DIR}/GDCMLibraryDepends.cmake) -CONFIGURE_FILE(${GDCM_SOURCE_DIR}/GDCMConfig.cmake.in - ${GDCM_BINARY_DIR}/GDCMConfig.cmake @ONLY IMMEDIATE) # For installed GDCM: SET(GDCM_USE_FILE ${CMAKE_INSTALL_PREFIX}/lib/GDCM-${GDCM_VERSION}/GDCMUse.cmake) SET(GDCM_INCLUDE_DIRS ${CMAKE_INSTALL_PREFIX}/include/GDCM-${GDCM_VERSION}) -SET(GDCM_LIBRARY_DIRS ${CMAKE_INSTALL_PREFIX}/lib/ExodusII-${GDCM_VERSION}) +SET(GDCM_LIBRARY_DIRS ${CMAKE_INSTALL_PREFIX}/lib/GDCM-${GDCM_VERSION}) SET(GDCM_LIBRARY_DEPENDS_FILE ${CMAKE_INSTALL_PREFIX}/lib/GDCM-${GDCM_VERSION}/GDCMLibraryDepends.cmake) CONFIGURE_FILE(${GDCM_SOURCE_DIR}/GDCMConfig.cmake.in - ${GDCM_BINARY_DIR}/Utilities/GDCMConfig.cmake @ONLY IMMEDIATE) + ${GDCM_BINARY_DIR}/GDCMConfig.cmake @ONLY IMMEDIATE) #----------------------------------------------------------------------------- # Test if compiler defines the pseudo-macro __FUNCTION__ @@ -77,34 +88,24 @@ IF("GDCM_COMPILER_HAS_FUNCTION" MATCHES "^GDCM_COMPILER_HAS_FUNCTION$") ENDIF("GDCM_COMPILER_HAS_FUNCTION" MATCHES "^GDCM_COMPILER_HAS_FUNCTION$") #----------------------------------------------------------------------------- -# Test if os defines a lenght for sockaddr -IF("HAVE_SA_LEN" MATCHES "^HAVE_SA_LEN$") - STRING(ASCII 35 POUND) - FILE(WRITE ${GDCM_BINARY_DIR}/CMakeTmp/gdcmTestHAVESALEN.c - "${POUND}include \n" - "${POUND}include \n" - "int main() { struct sockaddr sa; sa.sa_len = 0; }") - MESSAGE(STATUS "Checking if ifreq has a sa_len") - TRY_COMPILE(HAVE_SA_LEN - ${GDCM_BINARY_DIR} - ${GDCM_BINARY_DIR}/CMakeTmp/gdcmTestHAVESALEN.c - OUTPUT_VARIABLE OUTPUT) - IF(HAVE_SA_LEN) - MESSAGE(STATUS "Checking if ifreq has a sa_len -- yes") - SET(HAVE_SA_LEN 1 CACHE INTERNAL "Support if ifreq has a sa_len") - WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeOutput.log - "Determining if ifreq has a sa_len" - "passed with the following output:\n" - "${OUTPUT}\n" APPEND) - ELSE(HAVE_SA_LEN) - MESSAGE(STATUS "Checking if ifreq has a sa_len -- no") - SET(HAVE_SA_LEN 0 CACHE INTERNAL "Support if ifreq has a sa_len") - WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeError.log - "Determining if ifreq has a sa_len" - "failed with the following output:\n" - "${OUTPUT}\n" APPEND) - ENDIF(HAVE_SA_LEN) -ENDIF("HAVE_SA_LEN" MATCHES "^HAVE_SA_LEN$") +# Test is compiler support istringstream +IF("GDCM_TEST_ISTRINGSTREAM" MATCHES "^GDCM_TEST_ISTRINGSTREAM$") + MESSAGE(STATUS "Checking istringstream") + TRY_RUN(GDCM_TEST_ISTRINGSTREAM GDCM_TEST_ISTRINGSTREAM_COMPILED + ${GDCM_BINARY_DIR}/CMakeTmp/ + ${GDCM_SOURCE_DIR}/CMake/gdcmTestIstringStream.cxx) + IF(GDCM_TEST_ISTRINGSTREAM_COMPILED) + IF(GDCM_TEST_ISTRINGSTREAM) + MESSAGE(STATUS "Checking istringstream works -- yes") + SET(GDCM_TEST_ISTRINGSTREAM 1 CACHE INTERNAL "Whether istringstream works.") + ELSE(GDCM_TEST_ISTRINGSTREAM) + MESSAGE(STATUS "Checking istringstream works -- no") + SET(GDCM_TEST_ISTRINGSTREAM 0 CACHE INTERNAL "Whether istringstream works.") + ENDIF(GDCM_TEST_ISTRINGSTREAM) + ELSE(GDCM_TEST_ISTRINGSTREAM_COMPILED) + MESSAGE(STATUS "Checking istringstream -- failed") + ENDIF(GDCM_TEST_ISTRINGSTREAM_COMPILED) +ENDIF("GDCM_TEST_ISTRINGSTREAM" MATCHES "^GDCM_TEST_ISTRINGSTREAM$") #----------------------------------------------------------------------------- # Build directory on which many applications depend @@ -129,7 +130,11 @@ FIND_PATH(GDCM_DATA_ROOT gdcm-ACR-LibIDO.acr ) # Set the place for the public dictionary, must be set before gdcmConfigure.h -SET( GDCM_PUB_DICT_PATH "${CMAKE_INSTALL_PREFIX}${GDCM_DATA_DIR}") +#SET( GDCM_PUB_DICT_PATH "${CMAKE_INSTALL_PREFIX}${GDCM_DATA_DIR}") +FIND_PATH(GDCM_PUB_DICT_PATH dicomV3.dic + ${GDCM_SOURCE_DIR}/Dicts + $ENV{PUB_DICT_PATH} +) #----------------------------------------------------------------------------- # SunOS + old gcc fixes: @@ -137,12 +142,19 @@ INCLUDE (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityCXX.cmake) IF(CMAKE_NO_ANSI_STRING_STREAM) SET(GDCM_NO_ANSI_STRING_STREAM 1) ENDIF(CMAKE_NO_ANSI_STRING_STREAM) + +# Big endian thing: INCLUDE (${CMAKE_ROOT}/Modules/TestBigEndian.cmake) TEST_BIG_ENDIAN(GDCM_WORDS_BIGENDIAN) INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake) CHECK_INCLUDE_FILE("stdint.h" CMAKE_HAVE_STDINT_H) -CHECK_INCLUDE_FILE("inttypes.h" CMAKE_HAVE_INTTYPES_H) +IF(UNIX) #Avoid polluting Win32 cmakecache + CHECK_INCLUDE_FILE("inttypes.h" CMAKE_HAVE_INTTYPES_H) +ENDIF(UNIX) +# Special Time support, two convention: *NIX vs Win32 +CHECK_INCLUDE_FILE("sys/times.h" CMAKE_HAVE_SYS_TIMES_H) +CHECK_INCLUDE_FILE("sys/timeb.h" CMAKE_HAVE_SYS_TIMEB_H) # Check if header file exists and add it to the list. INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFiles.cmake) @@ -158,13 +170,48 @@ ENDMACRO(CHECK_INCLUDE_FILE_CONCAT) # test the inclusion of files CHECK_INCLUDE_FILE_CONCAT("unistd.h" CMAKE_HAVE_UNISTD_H) CHECK_INCLUDE_FILE_CONCAT("stdlib.h" CMAKE_HAVE_STDLIB_H) -CHECK_INCLUDE_FILE_CONCAT("sys/ioctl.h" CMAKE_HAVE_SYS_IOCTL_H) -CHECK_INCLUDE_FILE_CONCAT("sys/socket.h" CMAKE_HAVE_SYS_SOCKET_H) -CHECK_INCLUDE_FILE_CONCAT("sys/sockio.h" CMAKE_HAVE_SYS_SOCKIO_H) -CHECK_INCLUDE_FILE_CONCAT("net/if.h" CMAKE_HAVE_NET_IF_H) -CHECK_INCLUDE_FILE_CONCAT("netinet/in.h" CMAKE_HAVE_NETINET_IN_H) -CHECK_INCLUDE_FILE_CONCAT("net/if_dl.h" CMAKE_HAVE_NET_IF_DL_H) -CHECK_INCLUDE_FILE_CONCAT("net/if_arp.h" CMAKE_HAVE_NET_IF_ARP_H) +IF(UNIX) #Avoid polluting Win32 cmakecache + CHECK_INCLUDE_FILE_CONCAT("sys/ioctl.h" CMAKE_HAVE_SYS_IOCTL_H) + CHECK_INCLUDE_FILE_CONCAT("sys/socket.h" CMAKE_HAVE_SYS_SOCKET_H) + CHECK_INCLUDE_FILE_CONCAT("sys/sockio.h" CMAKE_HAVE_SYS_SOCKIO_H) + CHECK_INCLUDE_FILE_CONCAT("net/if.h" CMAKE_HAVE_NET_IF_H) + CHECK_INCLUDE_FILE_CONCAT("netinet/in.h" CMAKE_HAVE_NETINET_IN_H) + CHECK_INCLUDE_FILE_CONCAT("net/if_dl.h" CMAKE_HAVE_NET_IF_DL_H) + CHECK_INCLUDE_FILE_CONCAT("net/if_arp.h" CMAKE_HAVE_NET_IF_ARP_H) +ENDIF(UNIX) + +#----------------------------------------------------------------------------- +# Test if os defines a lenght for sockaddr +# only doing the test when we have sys/socket +IF( ${CMAKE_HAVE_SYS_SOCKET_H} ) + IF("HAVE_SA_LEN" MATCHES "^HAVE_SA_LEN$") + STRING(ASCII 35 POUND) + FILE(WRITE ${GDCM_BINARY_DIR}/CMakeTmp/gdcmTestHAVESALEN.c + "${POUND}include \n" + "${POUND}include \n" + "int main() { struct sockaddr sa; sa.sa_len = 0; }") + MESSAGE(STATUS "Checking if ifreq has a sa_len") + TRY_COMPILE(HAVE_SA_LEN + ${GDCM_BINARY_DIR} + ${GDCM_BINARY_DIR}/CMakeTmp/gdcmTestHAVESALEN.c + OUTPUT_VARIABLE OUTPUT) + IF(HAVE_SA_LEN) + MESSAGE(STATUS "Checking if ifreq has a sa_len -- yes") + SET(HAVE_SA_LEN 1 CACHE INTERNAL "Support if ifreq has a sa_len") + WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeOutput.log + "Determining if ifreq has a sa_len" + "passed with the following output:\n" + "${OUTPUT}\n" APPEND) + ELSE(HAVE_SA_LEN) + MESSAGE(STATUS "Checking if ifreq has a sa_len -- no") + SET(HAVE_SA_LEN 0 CACHE INTERNAL "Support if ifreq has a sa_len") + WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeError.log + "Determining if ifreq has a sa_len" + "failed with the following output:\n" + "${OUTPUT}\n" APPEND) + ENDIF(HAVE_SA_LEN) + ENDIF("HAVE_SA_LEN" MATCHES "^HAVE_SA_LEN$") +ENDIF( ${CMAKE_HAVE_SYS_SOCKET_H} ) #----------------------------------------------------------------------------- # Force Big Endian emulation on little endian: @@ -173,13 +220,16 @@ OPTION(GDCM_FORCE_BIGENDIAN_EMULATION "Force Big Endian Emulation. Do use if you CONFIGURE_FILE(${GDCM_SOURCE_DIR}/gdcmConfigure.h.in ${GDCM_BINARY_DIR}/gdcmConfigure.h @ONLY IMMEDIATE) -INSTALL_FILES(/include .h gdcmConfigure.h) +INSTALL_FILES(/include/gdcm .h gdcmConfigure.h) +INSTALL_FILES(/lib .cmake GDCMBuildSettings GDCMConfig GDCMLibraryDepends) #----------------------------------------------------------------------------- # Add the testing directories OPTION(BUILD_TESTING "Build testing." ON) IF(BUILD_TESTING) + CONFIGURE_FILE(${GDCM_SOURCE_DIR}/CMake/CTestCustom.ctest.in + ${GDCM_BINARY_DIR}/CMake/CTestCustom.ctest @ONLY) ENABLE_TESTING() INCLUDE (${CMAKE_ROOT}/Modules/Dart.cmake) MARK_AS_ADVANCED(DART_ROOT) @@ -222,3 +272,14 @@ IF(GDCM_DOCUMENTATION) ENDIF(DOXYGEN) ENDIF(GDCM_DOCUMENTATION) +#----------------------------------------------------------------------------- +IF(WIN32) + OPTION(GDCM_INSTALLER "Build the install setup using InnoSetup." OFF) +ENDIF(WIN32) +IF(UNIX) + OPTION(GDCM_INSTALLER "Prepare the rpmBuild use." OFF) +ENDIF(UNIX) +IF(GDCM_INSTALLER) + SUBDIRS(Builder) +ENDIF(GDCM_INSTALLER) +