CMakeLists.txt 12 KB
Newer Older
Andy Cedilnik's avatar
Andy Cedilnik committed
1
## Copyright 2003 Sandia Coporation
2
3
4
5
## Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
## the U.S. Government retains certain rights in this software.
##
## This source code is released under the New BSD License.
Andy Cedilnik's avatar
Andy Cedilnik committed
6
7
#

8
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
Andy Cedilnik's avatar
Andy Cedilnik committed
9

10
11
12
13
14
15
16
17
18
# Turn off policy 0017, which makes modules packaged with CMake find
# any module rather than just others packaged with CMake.  This is
# necessary for backward compatibility when included from ParaView.
IF (POLICY CMP0017)
  CMAKE_POLICY(SET CMP0017 OLD)
ENDIF (POLICY CMP0017)

PROJECT(ICET C)

Kenneth Moreland's avatar
Kenneth Moreland committed
19
# Set the current IceT version.
20
SET(ICET_MAJOR_VERSION 2)
Kenneth Moreland's avatar
Kenneth Moreland committed
21
22
SET(ICET_MINOR_VERSION 1)
SET(ICET_PATCH_VERSION 0)
23
SET(ICET_VERSION "${ICET_MAJOR_VERSION}.${ICET_MINOR_VERSION}.${ICET_PATCH_VERSION}")
Andy Cedilnik's avatar
Andy Cedilnik committed
24
25

# Set output paths.
26
SET(LIBRARY_OUTPUT_PATH ${ICET_BINARY_DIR}/lib CACHE PATH
27
  "Output directory for building all libraries.")
Andy Cedilnik's avatar
Andy Cedilnik committed
28
SET(EXECUTABLE_OUTPUT_PATH ${ICET_BINARY_DIR}/bin CACHE PATH
29
  "Output directory for building all executable.")
Andy Cedilnik's avatar
Andy Cedilnik committed
30
MARK_AS_ADVANCED(LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH)
31
32
SET(ICET_LIBRARY_DIR ${LIBRARY_OUTPUT_PATH})
SET(ICET_EXECUTABLE_DIR ${EXECUTABLE_OUTPUT_PATH})
Andy Cedilnik's avatar
Andy Cedilnik committed
33
34
SET(C_TEST_PATH ${EXECUTABLE_OUTPUT_PATH})

35
36
37
38
39
SET(CMAKE_MODULE_PATH
  ${CMAKE_MODULE_PATH}
  ${CMAKE_SOURCE_DIR}/cmake
  )

Andy Cedilnik's avatar
Andy Cedilnik committed
40
# Turn shared libraries on or off.
Kenneth Moreland's avatar
Kenneth Moreland committed
41
OPTION(BUILD_SHARED_LIBS "Build IceT with shared libraries." OFF)
Andy Cedilnik's avatar
Andy Cedilnik committed
42
43
SET(ICET_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})

44
45
46
47
# Options controlling support libraries
OPTION(ICET_USE_OPENGL "Build OpenGL support layer for IceT." ON)
OPTION(ICET_USE_MPI "Build MPI communication layer for IceT." ON)

48
49
50
# Option to set the preferred K value to use in the radix-k algorithm
SET(initial_magic_k 8)
IF ("${CMAKE_SYSTEM_NAME}" MATCHES "^BlueGene")
51
  SET(initial_magic_k 16)
52
53
54
55
56
57
58
59
60
61
62
ENDIF ("${CMAKE_SYSTEM_NAME}" MATCHES "^BlueGene")
IF ("$ENV{ICET_MAGIC_K}" GREATER 1)
  SET(initial_magic_k $ENV{ICET_MAGIC_K})
ENDIF ("$ENV{ICET_MAGIC_K}" GREATER 1)
SET(ICET_MAGIC_K ${initial_magic_k} CACHE STRING
  "Sets the preferred `k' value for the radix-k algorithm.  This is the amount of simultaneous messages each process receives.  A value of 8 is generally good on most architectures, but in others that have slower computation with respect to network (such as BlueGene), a larger value may give better performance."
  )
IF (NOT ${ICET_MAGIC_K} GREATER 1)
  MESSAGE(SEND_ERROR "ICET_MAGIC_K must be set to a number greater than 1.")
ENDIF (NOT ${ICET_MAGIC_K} GREATER 1)

63
# Option to set the preferred number of ways to break up an image.
64
SET(initial_max_image_split 512)
65
66
67
68
69
70
71
IF ("$ENV{ICET_MAX_IMAGE_SPLIT}" GREATER 0)
  SET(initial_max_image_split $ENV{ICET_MAX_IMAGE_SPLIT})
ENDIF ("$ENV{ICET_MAX_IMAGE_SPLIT}" GREATER 0)
SET(ICET_MAX_IMAGE_SPLIT ${initial_max_image_split} CACHE STRING
  "Sets the preferred number of times an image may be split.  Some image compositing algorithms prefer to partition the images such that each process gets a piece.  Too many partitions, though, and you end up spending more time collecting them than you save balancing the compositing."
  )

72
73
74
75
76
77
# Configure MPE support
IF (ICET_USE_MPI)
  OPTION(ICET_USE_MPE "Use MPE to trace MPI communications.  This is helpful for developers trying to measure the performance of parallel compositing algorithms." OFF)
  MARK_AS_ADVANCED(ICET_USE_MPE)
ENDIF (ICET_USE_MPI)

Andy Cedilnik's avatar
Andy Cedilnik committed
78
# Configure testing support.
Alexander Neundorf's avatar
   
Alexander Neundorf committed
79
INCLUDE(Dart)
Andy Cedilnik's avatar
Andy Cedilnik committed
80
81
82
83
84
85
86
87
IF (BUILD_TESTING)
  ENABLE_TESTING()
ENDIF (BUILD_TESTING)

IF (CMAKE_BUILD_TYPE MATCHES "Debug")
  ADD_DEFINITIONS(-DDEBUG)
ENDIF (CMAKE_BUILD_TYPE MATCHES "Debug")

88
89
90
IF (UNIX)
  LINK_LIBRARIES(m)
ENDIF (UNIX)
Andy Cedilnik's avatar
Andy Cedilnik committed
91
92

# Configure OpenGL support.
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
IF (ICET_USE_OPENGL)
  FIND_PACKAGE(OpenGL)
  IF (OPENGL_FOUND)
    INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
    SET(ICET_OPENGL_LIBRARIES ${OPENGL_LIBRARIES})
  ELSE (OPENGL_FOUND)
    FIND_PACKAGE(OSMesa)
    IF (OSMESA_INCLUDE_DIR AND OSMESA_LIBRARY)
      INCLUDE_DIRECTORIES(${OSMESA_INCLUDE_DIR})
      SET(ICET_OPENGL_LIBRARIES ${OSMESA_LIBRARY})
    ELSE(OSMESA_INCLUDE_DIR AND OSMESA_LIBRARY)
      MESSAGE(SEND_ERROR "Could not find OpenGL or OSMesa, which is required when ICET_USE_OPENGL is ON.")
    ENDIF (OSMESA_INCLUDE_DIR AND OSMESA_LIBRARY)
  ENDIF (OPENGL_FOUND)
ENDIF (ICET_USE_OPENGL)
Andy Cedilnik's avatar
Andy Cedilnik committed
108
109

# Configure MPI support.
110
111
112
113
114
115
IF (ICET_USE_MPI)
  FIND_PACKAGE(MPI REQUIRED)
  MARK_AS_ADVANCED(CLEAR MPI_INCLUDE_PATH)
  MARK_AS_ADVANCED(CLEAR MPI_LIBRARY)
  MARK_AS_ADVANCED(CLEAR MPI_EXTRA_LIBRARY)

Andy Cedilnik's avatar
Andy Cedilnik committed
116
  INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH})
117
118
119
120
121
  SET(ICET_MPI_LIBRARIES ${MPI_LIBRARY})
  
  IF(MPI_EXTRA_LIBRARY)
    SET(ICET_MPI_LIBRARIES ${ICET_MPI_LIBRARIES} ${MPI_EXTRA_LIBRARY})
  ENDIF(MPI_EXTRA_LIBRARY)
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141

  # Set up variables used to run MPI programs.  In CMake 2.8 or later, they are
  # defined by the FindMPI module.
  IF (MPIEXEC)
    SET(ICET_MPIRUN_EXE ${MPIEXEC})
    SET(ICET_MPI_NUMPROC_FLAG ${MPIEXEC_NUMPROC_FLAG})
    SET(ICET_MPI_PREFLAGS ${MPIEXEC_PREFLAGS})
    SET(ICET_MPI_POSTFLAGS ${MPIEXEC_POSTFLAGS})
  ELSE (MPIEXEC)
    FIND_PROGRAM(ICET_MPIRUN_EXE NAMES mpiexec mpirun lamexec)
    SET(ICET_MPI_NUMPROC_FLAG "-np" CACHE STRING "Flag used by MPI start program.  Used to specify the number of processes.")
    SET(ICET_MPI_PREFLAGS "" CACHE STRING "Flags used by MPI start program.  These are placed directly before the executable.")
    SET(ICET_MPI_POSTFLAGS "" CACHE STRING "Flags used by MPI start program.  These are placed after all other flags.")
    MARK_AS_ADVANCED(
      ICET_MPIRUN_EXE
      ICET_MPI_NUMPROC_FLAG
      ICET_MPI_PREFLAGS
      ICET_MPI_POSTFLAGS
      )
  ENDIF (MPIEXEC)
Andy Cedilnik's avatar
Andy Cedilnik committed
142
  SET(ICET_MPI_MAX_NUMPROCS "2" CACHE STRING "Maximum number of processors available to run parallel applications.")
143
  MARK_AS_ADVANCED(ICET_MPI_MAX_NUMPROCS)
Andy Cedilnik's avatar
Andy Cedilnik committed
144
145
  SEPARATE_ARGUMENTS(ICET_MPI_PREFLAGS)
  SEPARATE_ARGUMENTS(ICET_MPI_POSTFLAGS)
146
147
148

  IF (ICET_USE_MPE)
    FIND_PACKAGE(MPE REQUIRED)
Kenneth Moreland's avatar
Kenneth Moreland committed
149
150
    INCLUDE_DIRECTORIES(${MPE_LOG_INCLUDE_PATH})
    SET(ICET_MPI_LIBRARIES ${MPE_LOG_LIBRARIES} ${ICET_MPI_LIBRARIES})
151
  ENDIF (ICET_USE_MPE)
152
153
154
155
156
ENDIF (ICET_USE_MPI)

# Add extra warnings when possible.  The IceT build should be clean.  I expect
# no warnings when bulding this code.
IF (CMAKE_COMPILER_IS_GNUCC)
157
  SET(ICET_C_FLAGS_WARN "-ansi -Wall -Wno-long-long -Wcast-align -Wextra -Wformat-security -Wshadow -Wunused -Wreturn-type -Wpointer-arith -Wdeclaration-after-statement")
158
159
160
161
ENDIF (CMAKE_COMPILER_IS_GNUCC)

# Configure testing support.
IF (BUILD_TESTING)
Kenneth Moreland's avatar
Kenneth Moreland committed
162
  OPTION(ICET_BUILD_TESTING "Build and run the IceT tests." ON)
163
  MARK_AS_ADVANCED(ICET_BUILD_TESTING)
Andy Cedilnik's avatar
Andy Cedilnik committed
164
165
ENDIF (BUILD_TESTING)

166
# Configure data type sizes.
Alexander Neundorf's avatar
   
Alexander Neundorf committed
167
INCLUDE (CheckTypeSize)
168
169
170
171
172
173
174
175
176
CHECK_TYPE_SIZE(char        ICET_SIZEOF_CHAR)
CHECK_TYPE_SIZE(short       ICET_SIZEOF_SHORT)
CHECK_TYPE_SIZE(int         ICET_SIZEOF_INT)
CHECK_TYPE_SIZE(long        ICET_SIZEOF_LONG)
CHECK_TYPE_SIZE("long long" ICET_SIZEOF_LONG_LONG)
CHECK_TYPE_SIZE(__int64     ICET_SIZEOF___INT64)
CHECK_TYPE_SIZE(float       ICET_SIZEOF_FLOAT)
CHECK_TYPE_SIZE(double      ICET_SIZEOF_DOUBLE)
CHECK_TYPE_SIZE("void*"     ICET_SIZEOF_VOID_P)
Andy Cedilnik's avatar
Andy Cedilnik committed
177

178
179
180
181
#-----------------------------------------------------------------------------
# Configure install locations.  This allows parent projects to modify
# the install location.
IF(NOT ICET_INSTALL_BIN_DIR)
182
  SET(ICET_INSTALL_BIN_DIR bin)
183
184
ENDIF(NOT ICET_INSTALL_BIN_DIR)
IF(NOT ICET_INSTALL_INCLUDE_DIR)
185
  SET(ICET_INSTALL_INCLUDE_DIR include)
186
187
ENDIF(NOT ICET_INSTALL_INCLUDE_DIR)
IF(NOT ICET_INSTALL_LIB_DIR)
188
  SET(ICET_INSTALL_LIB_DIR lib)
189
ENDIF(NOT ICET_INSTALL_LIB_DIR)
190
191
192
IF(NOT ICET_INSTALL_MAN_DIR)
  SET(ICET_INSTALL_MAN_DIR share/man)
ENDIF(NOT ICET_INSTALL_MAN_DIR)
David Partyka's avatar
David Partyka committed
193
194
195
IF(NOT ICET_INSTALL_EXPORT_NAME)
  SET(ICET_INSTALL_EXPORT_NAME IceTTargets)
ENDIF()
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211

# Shared libraries are considered both runtime and development and
# static libraries are considered development only.  In order to
# switch library installation on and off correctly we make the
# decision here.
SET(ICET_INSTALL_NO_LIBRARIES)
IF(BUILD_SHARED_LIBS)
  IF(ICET_INSTALL_NO_RUNTIME AND ICET_INSTALL_NO_DEVELOPMENT)
    SET(ICET_INSTALL_NO_LIBRARIES 1)
  ENDIF(ICET_INSTALL_NO_RUNTIME AND ICET_INSTALL_NO_DEVELOPMENT)
ELSE(BUILD_SHARED_LIBS)
  IF(ICET_INSTALL_NO_DEVELOPMENT)
    SET(ICET_INSTALL_NO_LIBRARIES 1)
  ENDIF(ICET_INSTALL_NO_DEVELOPMENT)
ENDIF(BUILD_SHARED_LIBS)

Andy Cedilnik's avatar
Andy Cedilnik committed
212
# Configure files with settings for use by the build.
213
214
CONFIGURE_FILE(${ICET_SOURCE_DIR}/src/include/IceTConfig.h.in
               ${ICET_BINARY_DIR}/src/include/IceTConfig.h)
Andy Cedilnik's avatar
Andy Cedilnik committed
215

Kenneth Moreland's avatar
Kenneth Moreland committed
216
# Point to IceT include files.
Andy Cedilnik's avatar
Andy Cedilnik committed
217
218
219
INCLUDE_DIRECTORIES(${ICET_SOURCE_DIR}/src/include)
INCLUDE_DIRECTORIES(${ICET_BINARY_DIR}/src/include)

220
221
# When creating one of the IceT libraries, we want special instructions
# for building and installing.
222
SET(ICET_INSTALL_TARGETS "" CACHE INTERNAL "" FORCE)
223
MACRO(ICET_ADD_LIBRARY library_name)
224
  SET(ICET_INSTALL_TARGETS ${ICET_INSTALL_TARGETS} ${library_name}
225
    CACHE INTERNAL "" FORCE
226
    )
227
228
229
230
231
232
233
234
235
236
237
238
239
240
  SET(icet_library_sources ${ARGN})
  ADD_LIBRARY(${library_name} ${icet_library_sources})
  IF (ICET_C_FLAGS_WARN)
    SET_SOURCE_FILES_PROPERTIES(${icet_library_sources}
      PROPERTIES COMPILE_FLAGS ${ICET_C_FLAGS_WARN}
      )
  ENDIF (ICET_C_FLAGS_WARN)
  IF(NOT ICET_INSTALL_NO_LIBRARIES)
    INSTALL(TARGETS ${library_name}
      EXPORT ${ICET_INSTALL_EXPORT_NAME}
      RUNTIME DESTINATION ${ICET_INSTALL_BIN_DIR} COMPONENT RuntimeLibraries
      LIBRARY DESTINATION ${ICET_INSTALL_LIB_DIR} COMPONENT RuntimeLibraries
      ARCHIVE DESTINATION ${ICET_INSTALL_LIB_DIR} COMPONENT RuntimeLibraries
      )
241
    IF (NOT ICET_INSTALL_NO_DEVELOPMENT)
242
      INSTALL(EXPORT ${ICET_INSTALL_EXPORT_NAME}
243
244
245
	DESTINATION ${ICET_INSTALL_LIB_DIR}
	)
    ENDIF (NOT ICET_INSTALL_NO_DEVELOPMENT)
246
247
248
  ENDIF(NOT ICET_INSTALL_NO_LIBRARIES)
ENDMACRO(ICET_ADD_LIBRARY)

249
ADD_SUBDIRECTORY(src)
250

251
IF (BUILD_TESTING AND ICET_BUILD_TESTING)
252
253
254
255
256
  IF (ICET_USE_MPI)
    ADD_SUBDIRECTORY(tests)
  ELSE (ICET_USE_MPI)
    MESSAGE(STATUS "Tests require ICET_USE_MPI.  Disabling tests.")
  ENDIF (ICET_USE_MPI)
257
ENDIF (BUILD_TESTING AND ICET_BUILD_TESTING)
Andy Cedilnik's avatar
Andy Cedilnik committed
258

259
260
ADD_SUBDIRECTORY(doc)

261
262
263
264
# Save the CMake targets so another project can import them.
EXPORT(TARGETS ${ICET_INSTALL_TARGETS}
  FILE ${ICET_LIBRARY_DIR}/IceTTargets.cmake
  )
265

Kenneth Moreland's avatar
Kenneth Moreland committed
266
# Save IceT specific configuration options.
267

268
#First, configuration for build directory.
269
SET(ICET_INCLUDE_DIRS_CONFIG "${ICET_SOURCE_DIR}/src/include;${ICET_BINARY_DIR}/src/include")
270
271
272
273
274
275
276
277
278
279
280
281
282
SET(ICET_CORE_LIBRARY_TARGET IceTCore)
IF (ICET_USE_OPENGL)
  SET(ICET_GL_LIBRARY_TARGET IceTGL)
ENDIF (ICET_USE_OPENGL)
IF (ICET_USE_MPI)
  SET(ICET_MPI_LIBRARY_TARGET IceTMPI)
ENDIF (ICET_USE_MPI)
CONFIGURE_FILE(
  ${ICET_SOURCE_DIR}/cmake/IceTConfig.cmake.in
  ${ICET_LIBRARY_DIR}/IceTConfig.cmake
  @ONLY IMMEDIATE
  )

283
#Second, configuration for install directory.
284
IF (NOT ICET_INSTALL_NO_DEVELOPMENT)
285
  SET(ICET_INCLUDE_DIRS_CONFIG "\${_install_dir}/${ICET_INSTALL_INCLUDE_DIR}")
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
  SET(ICET_CORE_LIBRARY_TARGET IceTCore)
  IF (ICET_USE_OPENGL)
    SET(ICET_GL_LIBRARY_TARGET IceTGL)
  ENDIF (ICET_USE_OPENGL)
  IF (ICET_USE_MPI)
    SET(ICET_MPI_LIBRARY_TARGET IceTMPI)
  ENDIF (ICET_USE_MPI)
  CONFIGURE_FILE(
    ${ICET_SOURCE_DIR}/cmake/IceTConfig.cmake.in
    ${ICET_LIBRARY_DIR}/IceTConfig.cmake.install
    @ONLY IMMEDIATE)
  INSTALL(FILES ${ICET_LIBRARY_DIR}/IceTConfig.cmake.install
    DESTINATION ${ICET_INSTALL_LIB_DIR}
    RENAME IceTConfig.cmake
    )
ENDIF (NOT ICET_INSTALL_NO_DEVELOPMENT)

# Create supplemental version configuration file.
CONFIGURE_FILE(
  ${ICET_SOURCE_DIR}/cmake/IceTConfigVersion.cmake.in
  ${ICET_LIBRARY_DIR}/IceTConfigVersion.cmake
  @ONLY
  )
IF (NOT ICET_INSTALL_NO_DEVELOPMENT)
  INSTALL(FILES ${ICET_LIBRARY_DIR}/IceTConfigVersion.cmake
    DESTINATION ${ICET_INSTALL_LIB_DIR}
    )
ENDIF (NOT ICET_INSTALL_NO_DEVELOPMENT)
Andy Cedilnik's avatar
Andy Cedilnik committed
314

315
316
317
318
319
320
321
322
323
# Enable CPack packaging.
SET(CPACK_PACKAGE_DESCRIPTION_FILE ${ICET_SOURCE_DIR}/README)
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The Image Composition Engine for Tiles")
SET(CPACK_PACKAGE_NAME "IceT")
SET(CPACK_PACKAGE_VENDOR "Sandia National Laboratories")
SET(CPACK_PACKAGE_VERSION_MAJOR ${ICET_MAJOR_VERSION})
SET(CPACK_PACKAGE_VERSION_MINOR ${ICET_MINOR_VERSION})
SET(CPACK_PACKAGE_VERSION_PATCH ${ICET_PATCH_VERSION})
INCLUDE(CPack)
Andy Cedilnik's avatar
Andy Cedilnik committed
324
325
326
327

# Allow local additions to this file without CVS conflicts.
INCLUDE(${ICET_BINARY_DIR}/LocalUserOptions.cmake OPTIONAL)
INCLUDE(${ICET_SOURCE_DIR}/LocalUserOptions.cmake OPTIONAL)