CMakeLists.txt 6.37 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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 2)
SET(GDCM_BUILD_VERSION 2)
SET(GDCM_VERSION 
    "${GDCM_MAJOR_VERSION}.${GDCM_MINOR_VERSION}.${GDCM_BUILD_VERSION}")

#-----------------------------------------------------------------------------
# datadir in CMake:
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
SET(GDCM_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})

#OPTION(GDCM_DEBUG "Turn verbosity of some statement ON." OFF)
#MARK_AS_ADVANCED(GDCM_DEBUG)
SET(GDCM_DEBUG 0)

#-----------------------------------------------------------------------------
# Test if compiler defines the pseudo-macro __FUNCTION__
IF("GDCM_COMPILER_HAS_FUNCTION" MATCHES "^GDCM_COMPILER_HAS_FUNCTION$")
  MESSAGE(STATUS "Checking support for __FUNCTION__ in compiler")
  TRY_COMPILE(GDCM_COMPILER_HAS_FUNCTION
              ${GDCM_BINARY_DIR}/CMakeTmp/Function
              ${GDCM_SOURCE_DIR}/CMake/gdcmTestFUNCTION.cxx
              OUTPUT_VARIABLE OUTPUT)
  IF(GDCM_COMPILER_HAS_FUNCTION)
    MESSAGE(STATUS "Checking support for __FUNCTION__ -- yes")
    SET(GDCM_COMPILER_HAS_FUNCTION 1 CACHE INTERNAL "Support for extension C __FUNCTION__")
    WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeOutput.log
      "Determining if the C compiler supports __FUNCTION__ "
      "passed with the following output:\n"
      "${OUTPUT}\n" APPEND)
  ELSE(GDCM_COMPILER_HAS_FUNCTION)
    MESSAGE(STATUS "Checking support for __FUNCTION__ -- no")
    SET(GDCM_COMPILER_HAS_FUNCTION 0 CACHE INTERNAL "Support for extension C __FUNCTION__")
    WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeError.log
      "Determining if the C compiler supports __FUNCTION__ "
      "failed with the following output:\n"
      "${OUTPUT}\n" APPEND)
  ENDIF(GDCM_COMPILER_HAS_FUNCTION)
ENDIF("GDCM_COMPILER_HAS_FUNCTION" MATCHES "^GDCM_COMPILER_HAS_FUNCTION$")

#-----------------------------------------------------------------------------
# Build directory on which many applications depend
60
61
62

# ADDED BY OTB DEVELOPPERS TO AVOID INTENSIVE RECOMPILATION
IF(NOT DISABLE_OTB_UTILITIES_COMPILATION)
63
64
65
66
SUBDIRS(
  Dicts
  src
)
67
ENDIF(NOT DISABLE_OTB_UTILITIES_COMPILATION)
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157

# Set the place for the public dictionary, must be set before gdcmConfigure.h
SET( GDCM_PUB_DICT_PATH "${CMAKE_INSTALL_PREFIX}${GDCM_DATA_DIR}")

#-----------------------------------------------------------------------------
# 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)
IF(UNIX) #Avoid polluting Win32 cmakecache
  CHECK_INCLUDE_FILE("inttypes.h"     CMAKE_HAVE_INTTYPES_H)
ENDIF(UNIX)

# Check if header file exists and add it to the list.
INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFiles.cmake)
MACRO(CHECK_INCLUDE_FILE_CONCAT FILE VARIABLE)
  CHECK_INCLUDE_FILES("${GDCM_INCLUDES};${FILE}" ${VARIABLE})
  IF(${VARIABLE})
    SET(GDCM_INCLUDES ${GDCM_INCLUDES} ${FILE})
  ENDIF(${VARIABLE})
ENDMACRO(CHECK_INCLUDE_FILE_CONCAT)

# Need those header for GetMacAddress in Util
# This is tricky as you need to figure out the proper order to
# 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)
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 length 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 <sys/types.h>\n"
      "${POUND}include <sys/socket.h>\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} )

#-----------------------------------------------------------------------------
# Do the OpenJPEG export thing
IF (WIN32)
  IF (BUILD_SHARED_LIBS)
    SET(OPJ_EXPORTS 1)
  ELSE (BUILD_SHARED_LIBS)
    SET(OPJ_STATIC 1)
  ENDIF (BUILD_SHARED_LIBS)
ENDIF (WIN32)


CONFIGURE_FILE(${GDCM_SOURCE_DIR}/gdcmConfigure.h.in
               ${GDCM_BINARY_DIR}/gdcmConfigure.h @ONLY IMMEDIATE)

INSTALL(FILES ${GDCM_BINARY_DIR}/gdcmConfigure.h
  DESTINATION ${ITK_INSTALL_INCLUDE_DIR_CM24}/gdcm/src
  COMPONENT Development)