From 6ab7853638f8dc05d71f7c6ce2adb4f161d863cd Mon Sep 17 00:00:00 2001 From: malaterre Date: Fri, 14 Nov 2003 14:51:24 +0000 Subject: [PATCH] * ENH: Update CMake stuff for accessing gdcm from CMake (4 third party lib) * FIX: Compilation for SunOS + old gcc --- CMakeLists.txt | 29 ++++++++++++++++++++++++++--- gdcmConfig.cmake.in | 34 ++++++++++++++++++++++++++++++++++ gdcmUse.cmake | 13 +++++++++++++ src/CMakeLists.txt | 35 +++++++++++++++++++++++++++-------- src/gdcmCommon.h | 8 ++++++++ 5 files changed, 108 insertions(+), 11 deletions(-) create mode 100644 gdcmConfig.cmake.in create mode 100644 gdcmUse.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index afd17045..4433fd5f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,11 +95,34 @@ ENDIF(GDCM_DOXYGEN) #----------------------------------------------------------------------------- # Configure files with settings for use by the build. - +# for third party to access gdcm through cmake # to be rewritten to include only the necessary -#CONFIGURE_FILE(${GDCM_SOURCE_DIR}/UseGdcm.cmake.in -# ${GDCM_BINARY_DIR}/UseGdcm.cmake COPYONLY IMMEDIATE) +CONFIGURE_FILE( + ${GDCM_SOURCE_DIR}/gdcmConfig.cmake.in + ${GDCM_BINARY_DIR}/gdcmConfig.cmake @ONLY IMMEDIATE + ) + +# Export uor build settings and library +# dependencies for the use by the user projects. +INCLUDE( + ${CMAKE_ROOT}/Modules/CMakeExportBuildSettings.cmake) + +CMAKE_EXPORT_BUILD_SETTINGS( + ${GDCM_BINARY_DIR}/gdcmBuildSettings.cmake + ) + +EXPORT_LIBRARY_DEPENDENCIES( + ${GDCM_BINARY_DIR}/gdcmLibraryDepends.cmake + ) + +# Intall the âckaging files for use by FIND_PACKAGE(GDCM) in user projects. +INSTALL_FILES(/lin/gdcm FILES + ${GDCM_SOURCE_DIR}/gdcmUse.cmake + ${GDCM_BINARY_DIR}/gdcmConfig.cmake + ${GDCM_BINARY_DIR}/gdcmBuildSettings.cmake + ${GDCM_BINARY_DIR}/gdcmLibraryDepends.cmake + ) #----------------------------------------------------------------------------- # Copy / paste from old m4 script: diff --git a/gdcmConfig.cmake.in b/gdcmConfig.cmake.in new file mode 100644 index 00000000..a89e7c8a --- /dev/null +++ b/gdcmConfig.cmake.in @@ -0,0 +1,34 @@ +# Tell the user project where to find our headers and libraries + +SET(GDCM_INCLUDE_DIRS + #"@CMAKE_INSTALL_PREFIX@/include" + "@GDCM_SOURCE_DIR@/src" + "@GDCM_SOURCE_DIR@/vtk" + ) + +SET(GDCM_LIBRARY_DIRS + #"@CMAKE_INSTALL_PREFIX@/lib" + "@GDCM_LIBRARY_PATH@" + ) + +# Tell the user project where to find your build +# settings and library dependencies +SET(GDCM_BUILD_SETTING_FILE +# "@CMAKE_INSTALL_PREFIX@/lib/gdcm/gdcmBuildSettings.cmake +# "@CMAKE_INSTALL_PREFIX@/lib/gdcmBuildSettings.cmake" + "@GDCM_BINARY_DIR@/gdcmBuildSettings.cmake" + ) + +INCLUDE( +# "@CMAKE_INSTALL_PREFIX@/lib/gdcm/gdcmLibraryDepends.cmake" +# "@CMAKE_INSTALL_PREFIX@/lib/gdcmLibraryDepends.cmake" + "@GDCM_BINARY_DIR@/gdcmLibraryDepends.cmake" + ) + +# Tell the user project where to find the "USE" file. +# This file uses the above settings to configure the user project. + +SET(GDCM_USE_FILE +# "@CMAKE_INSTALL_PREFIX@/lib/gdcm/gdcmUse.cmake" + "@GDCM_SOURCE_DIR@/gdcmUse.cmake" + ) diff --git a/gdcmUse.cmake b/gdcmUse.cmake new file mode 100644 index 00000000..9ca4147f --- /dev/null +++ b/gdcmUse.cmake @@ -0,0 +1,13 @@ +# Import GDCM's build settings. + +INCLUDE( + ${CMAKE_ROOT}/Modules/CMake/CMAkeImportBuildSettings.cmake + ) + +CMAKE_IMPORT_BUILD_SETTINGS(${GDCM_BUILD_SETTINGS_FILE}) + +# Tell the compiler where to find GDCM's header files. +INCLUDE_DIRECTORIES(${GDCM_INCLUDE_DIRS}) + +# Tell the linker where to find GDCM's libraries. +LINK_DIRECTORIES(${GDCM_LIBRARY_DIRS}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7d5ba71d..3e31dd4a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -38,17 +38,36 @@ SET(libgdcm_la_SOURCES # http://www.cmake.org/pipermail/cmake/2003-October/004369.html # http://www.cmake.org/pipermail/cmake/2003-October/004373.html -SET_SOURCE_FILES_PROPERTIES(${libgdcm_la_SOURCES} - PROPERTIES - COMPILE_FLAGS "-D__STDC_LIMIT_MACROS -DPUB_DICT_PATH=\\\"${CMAKE_INSTALL_PREFIX}${GDCM_DATA_DIR}\\\"" -) +SET(GDCM_COMPILE_FLAGS + "-D__STDC_LIMIT_MACROS -DPUB_DICT_PATH=\\\"${CMAKE_INSTALL_PREFIX}${GDCM_DATA_DIR}\\\"" + ) + +# SunOS + old gcc fixes: + +INCLUDE (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityCXX.cmake) +IF(CMAKE_NO_ANSI_STRING_STREAM) +SET(GDCM_COMPILE_FLAGS + "${GDCM_COMPILE_FLAGS} -DGDCM_NO_ANSI_STRING_STREAM" + ) +ENDIF(CMAKE_NO_ANSI_STRING_STREAM) + +#INCLUDE (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityC.cmake) +#INCLUDE (${CMAKE_ROOT}/Modules/CheckTypeSize.cmake) + +INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake) +CHECK_INCLUDE_FILE("stdint.h" CMAKE_HAVE_STDINT_H) -IF(${CMAKE_NO_ANSI_STRING_STREAM}) -SET_SOURCE_FILES_PROPERTIES(gdcmHeader.cxx gdcmElValSet.cxx +#MESSAGE(STATUS ${CMAKE_NO_ANSI_STRING_STREAM}) +IF(NOT CMAKE_HAVE_STDINT_H) +SET(GDCM_COMPILE_FLAGS + "${GDCM_COMPILE_FLAGS} -DHAVE_NO_STDINT_H" + ) +ENDIF(NOT CMAKE_HAVE_STDINT_H) + +SET_SOURCE_FILES_PROPERTIES(${libgdcm_la_SOURCES} PROPERTIES - COMPILE_FLAGS "-DGDCM_NO_ANSI_STRING_STREAM" + COMPILE_FLAGS ${GDCM_COMPILE_FLAGS} ) -ENDIF(${CMAKE_NO_ANSI_STRING_STREAM}) ADD_LIBRARY(gdcm ${libgdcm_la_SOURCES} ) IF(UNIX) diff --git a/src/gdcmCommon.h b/src/gdcmCommon.h index a74d6d84..3db17d81 100644 --- a/src/gdcmCommon.h +++ b/src/gdcmCommon.h @@ -24,11 +24,19 @@ #endif //_MSC_VER #ifdef __GNUC__ +#ifndef HAVE_NO_STDINT_H #include #define guint16 uint16_t #define guint32 uint32_t #define gint16 int16_t #define gint32 int32_t +#else +typedef unsigned short guint16; +typedef unsigned int guint32; +typedef short gint16; +typedef int gint32; +#define UINT32_MAX (4294967295U) +#endif //HAVE_NO_STDINT_H #endif #ifdef _MSC_VER -- 2.45.1