-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
295 lines (261 loc) · 12.2 KB
/
CMakeLists.txt
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
60
61
62
63
64
65
66
67
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
## Copyright 2003 Sandia Coporation
## 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.
#
PROJECT(ICET C)
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
# Set the current IceT version.
SET(ICET_MAJOR_VERSION 2)
SET(ICET_MINOR_VERSION 0)
SET(ICET_PATCH_VERSION 0)
SET(ICET_VERSION "${ICET_MAJOR_VERSION}.${ICET_MINOR_VERSION}.${ICET_PATCH_VERSION}")
# Set output paths.
SET(LIBRARY_OUTPUT_PATH ${ICET_BINARY_DIR}/bin CACHE PATH
"Output directory for building all libraries.")
SET(EXECUTABLE_OUTPUT_PATH ${ICET_BINARY_DIR}/bin CACHE PATH
"Output directory for building all executable.")
MARK_AS_ADVANCED(LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH)
SET(ICET_LIBRARY_DIR ${LIBRARY_OUTPUT_PATH})
SET(ICET_EXECUTABLE_DIR ${EXECUTABLE_OUTPUT_PATH})
SET(C_TEST_PATH ${EXECUTABLE_OUTPUT_PATH})
SET(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
${CMAKE_SOURCE_DIR}/cmake
)
# Turn shared libraries on or off.
OPTION(BUILD_SHARED_LIBS "Build IceT with shared libraries." OFF)
SET(ICET_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
# 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)
# 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")
SET(initial_magic_k 16)
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)
# Option to set the preferred number of ways to break up an image.
SET(initial_max_image_split 512)
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."
)
# 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)
# Configure testing support.
INCLUDE(Dart)
IF (BUILD_TESTING)
ENABLE_TESTING()
ENDIF (BUILD_TESTING)
IF (CMAKE_BUILD_TYPE MATCHES "Debug")
ADD_DEFINITIONS(-DDEBUG)
ENDIF (CMAKE_BUILD_TYPE MATCHES "Debug")
IF (UNIX)
LINK_LIBRARIES(m)
ENDIF (UNIX)
# Configure OpenGL support.
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)
# Configure MPI support.
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)
INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH})
SET(ICET_MPI_LIBRARIES ${MPI_LIBRARY})
IF(MPI_EXTRA_LIBRARY)
SET(ICET_MPI_LIBRARIES ${ICET_MPI_LIBRARIES} ${MPI_EXTRA_LIBRARY})
ENDIF(MPI_EXTRA_LIBRARY)
# 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)
SET(ICET_MPI_MAX_NUMPROCS "2" CACHE STRING "Maximum number of processors available to run parallel applications.")
MARK_AS_ADVANCED(ICET_MPI_MAX_NUMPROCS)
SEPARATE_ARGUMENTS(ICET_MPI_PREFLAGS)
SEPARATE_ARGUMENTS(ICET_MPI_POSTFLAGS)
IF (ICET_USE_MPE)
FIND_PACKAGE(MPE REQUIRED)
INCLUDE_DIRECTORIES(${MPE_LOG_INCLUDE_PATH})
SET(ICET_MPI_LIBRARIES ${MPE_LOG_LIBRARIES} ${ICET_MPI_LIBRARIES})
ENDIF (ICET_USE_MPE)
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)
SET(ICET_C_FLAGS_WARN "-ansi -Wall -Wno-long-long -Wcast-align -Wextra -Wformat-security -Wshadow -Wunused -Wreturn-type -Wpointer-arith -Wdeclaration-after-statement")
ENDIF (CMAKE_COMPILER_IS_GNUCC)
# Configure testing support.
IF (BUILD_TESTING)
OPTION(ICET_BUILD_TESTING "Build and run the IceT tests." ON)
MARK_AS_ADVANCED(ICET_BUILD_TESTING)
ENDIF (BUILD_TESTING)
# Configure data type sizes.
INCLUDE (CheckTypeSize)
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)
#-----------------------------------------------------------------------------
# Configure install locations. This allows parent projects to modify
# the install location.
IF(NOT ICET_INSTALL_BIN_DIR)
SET(ICET_INSTALL_BIN_DIR bin)
ENDIF(NOT ICET_INSTALL_BIN_DIR)
IF(NOT ICET_INSTALL_INCLUDE_DIR)
SET(ICET_INSTALL_INCLUDE_DIR include)
ENDIF(NOT ICET_INSTALL_INCLUDE_DIR)
IF(NOT ICET_INSTALL_LIB_DIR)
SET(ICET_INSTALL_LIB_DIR lib)
ENDIF(NOT ICET_INSTALL_LIB_DIR)
IF(NOT ICET_INSTALL_MAN_DIR)
SET(ICET_INSTALL_MAN_DIR share/man)
ENDIF(NOT ICET_INSTALL_MAN_DIR)
IF(NOT ICET_INSTALL_EXPORT_NAME)
SET(ICET_INSTALL_EXPORT_NAME IceTTargets)
ENDIF()
# 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)
# Configure files with settings for use by the build.
CONFIGURE_FILE(${ICET_SOURCE_DIR}/src/include/IceTConfig.h.in
${ICET_BINARY_DIR}/src/include/IceTConfig.h)
# Point to IceT include files.
INCLUDE_DIRECTORIES(${ICET_SOURCE_DIR}/src/include)
INCLUDE_DIRECTORIES(${ICET_BINARY_DIR}/src/include)
# When creating one of the IceT libraries, we want special instructions
# for building and installing.
MACRO(ICET_ADD_LIBRARY library_name)
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
)
ENDIF(NOT ICET_INSTALL_NO_LIBRARIES)
ENDMACRO(ICET_ADD_LIBRARY)
ADD_SUBDIRECTORY(src)
IF (BUILD_TESTING AND ICET_BUILD_TESTING)
IF (ICET_USE_MPI)
ADD_SUBDIRECTORY(tests)
ELSE (ICET_USE_MPI)
MESSAGE(STATUS "Tests require ICET_USE_MPI. Disabling tests.")
ENDIF (ICET_USE_MPI)
ENDIF (BUILD_TESTING AND ICET_BUILD_TESTING)
ADD_SUBDIRECTORY(doc)
# Save the CMake settings so another project can import them. Loaded by:
# INCLUDE(${CMAKE_ROOT}/Modules/CMakeImportBuildSettings.cmake)
# CMAKE_IMPORT_BUILD_SETTINGS(<build_file>)
INCLUDE(CMakeExportBuildSettings)
CMAKE_EXPORT_BUILD_SETTINGS(${ICET_BINARY_DIR}/ICETBuildSettings.cmake)
INSTALL(FILES ${ICET_BINARY_DIR}/ICETBuildSettings.cmake DESTINATION ${ICET_INSTALL_LIB_DIR})
# Save the library dependency graph for external projects.
EXPORT_LIBRARY_DEPENDENCIES(${ICET_BINARY_DIR}/ICETLibraryDepends.cmake)
INSTALL(FILES ${ICET_BINARY_DIR}/ICETLibraryDepends.cmake DESTINATION ${ICET_INSTALL_LIB_DIR})
# Save IceT specific configuration options.
#First, configuration for build directory.
SET(ICET_INCLUDE_DIRS_CONFIG "${ICET_SOURCE_DIR}/src/include;${ICET_BINARY_DIR}/src/include")
SET(ICET_LIBRARY_DIRS_CONFIG ${ICET_LIBRARY_DIR})
SET(ICET_BUILD_SETTINGS_FILE_CONFIG ${ICET_BINARY_DIR}/ICETBuildSettings.cmake)
SET(ICET_LIBRARY_DEPENDS_FILE ${ICET_BINARY_DIR}/ICETLibraryDepends.cmake)
GET_TARGET_PROPERTY(ICET_LIBRARY_FILE IceTCore LOCATION)
GET_TARGET_PROPERTY(ICET_GL_LIBRARY_FILE IceTGL LOCATION)
GET_TARGET_PROPERTY(ICET_MPI_LIBRARY_FILE IceTMPI LOCATION)
CONFIGURE_FILE(${ICET_SOURCE_DIR}/IceTConfig.cmake.in
${ICET_BINARY_DIR}/IceTConfig.cmake @ONLY IMMEDIATE)
#Second, configuration for install directory.
SET(ICET_INCLUDE_DIRS_CONFIG ${CMAKE_INSTALL_PREFIX}${ICET_INSTALL_INCLUDE_DIR})
SET(ICET_LIBRARY_DIRS_CONFIG ${CMAKE_INSTALL_PREFIX}${ICET_INSTALL_LIB_DIR})
SET(ICET_BUILD_SETTINGS_FILE_CONFIG
${CMAKE_INSTALL_PREFIX}${ICET_INSTALL_LIB_DIR}/ICETBuildSettings.cmake)
SET(ICET_LIBRARY_DEPENDS_FILE
${CMAKE_INSTALL_PREFIX}${ICET_INSTALL_LIB_DIR}/ICETLibraryDepends.cmake)
GET_FILENAME_COMPONENT(ICET_LIBRARY_FILE "${ICET_LIBRARY_FILE}" NAME)
SET(ICET_LIBRARY_FILE "${CMAKE_INSTALL_PREFIX}${ICET_INSTALL_LIB_DIR}/${ICET_LIBRARY_FILE}")
GET_FILENAME_COMPONENT(ICET_GL_LIBRARY_FILE "${ICET_GL_LIBRARY_FILE}" NAME)
SET(ICET_GL_LIBRARY_FILE "${CMAKE_INSTALL_PREFIX}${ICET_INSTALL_LIB_DIR}/${ICET_GL_LIBRARY_FILE}")
GET_FILENAME_COMPONENT(ICET_MPI_LIBRARY_FILE "${ICET_MPI_LIBRARY_FILE}" NAME)
SET(ICET_MPI_LIBRARY_FILE "${CMAKE_INSTALL_PREFIX}${ICET_INSTALL_LIB_DIR}/${ICET_MPI_LIBRARY_FILE}")
CONFIGURE_FILE(${ICET_SOURCE_DIR}/IceTConfig.cmake.in
${ICET_LIBRARY_DIR}/IceTConfig.cmake @ONLY IMMEDIATE)
INSTALL(FILES ${ICET_LIBRARY_DIR}/IceTConfig.cmake DESTINATION ${ICET_INSTALL_LIB_DIR})
# 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)
# Allow local additions to this file without CVS conflicts.
INCLUDE(${ICET_BINARY_DIR}/LocalUserOptions.cmake OPTIONAL)
INCLUDE(${ICET_SOURCE_DIR}/LocalUserOptions.cmake OPTIONAL)