This repository has been archived by the owner on Jul 16, 2022. It is now read-only.
/
CMakeLists.txt
executable file
·229 lines (195 loc) · 10.8 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
CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)
PROJECT( FiberNavigator )
#set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE)
############ !!!! Visual Studio users should set the type in CMAKE !!!! ################
# This is ugly but forces Visual Studio to be equal to CMAKE_BUILD_TYPE
set(CMAKE_CONFIGURATION_TYPES ${CMAKE_BUILD_TYPE} CACHE STRING "" FORCE)
MARK_AS_ADVANCED( CMAKE_CONFIGURATION_TYPES )
# Include local CMake modules
LIST( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../tools/CMakeModules ${PROJECT_SOURCE_DIR}/../tools/rpavlik_cmakemodules )
# Version configuration
include(GetGitRevisionDescription)
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/version/VersionString.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/version/VersionString.cpp" @ONLY)
SET( VERSION_HDR "${CMAKE_CURRENT_SOURCE_DIR}/version/VersionString.h")
SET( VERSION_SRC "${CMAKE_CURRENT_BINARY_DIR}/version/VersionString.cpp")
# First of all find out which platform we are on and set our own platform variable
SET( FIBERNAVIGATOR_PLATFORM_LINUX "Linux" )
SET( FIBERNAVIGATOR_PLATFORM_WINDOWS "Windows" )
IF( CMAKE_HOST_SYSTEM MATCHES Linux )
SET( FIBERNAVIGATOR_PLATFORM
${FIBERNAVIGATOR_PLATFORM_LINUX}
CACHE STRING "The platform we are building on." )
ENDIF( CMAKE_HOST_SYSTEM MATCHES Linux )
IF( CMAKE_HOST_SYSTEM MATCHES Windows )
SET( FIBERNAVIGATOR_PLATFORM
${FIBERNAVIGATOR_PLATFORM_WINDOWS}
CACHE STRING "The platform we are building on." )
ENDIF( CMAKE_HOST_SYSTEM MATCHES Windows )
# Platform dependencies
IF( FIBERNAVIGATOR_PLATFORM MATCHES ${FIBERNAVIGATOR_PLATFORM_WINDOWS} )
SET( LIBRARY_OUTPUT_PATH
${PROJECT_BINARY_DIR}/bin
CACHE PATH "The libraries will be put into this directory.")
ELSE( FIBERNAVIGATOR_PLATFORM MATCHES ${FIBERNAVIGATOR_PLATFORM_WINDOWS} )
SET( LIBRARY_OUTPUT_PATH
${PROJECT_BINARY_DIR}/lib
CACHE PATH "The libraries will be put into this directory.")
ENDIF( FIBERNAVIGATOR_PLATFORM MATCHES ${FIBERNAVIGATOR_PLATFORM_WINDOWS} )
MARK_AS_ADVANCED( LIBRARY_OUTPUT_PATH )
SET( EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin CACHE PATH "The executables will be put into this directory.")
MARK_AS_ADVANCED( EXECUTABLE_OUTPUT_PATH )
# Set default build type
IF ( NOT CMAKE_BUILD_TYPE )
SET( CMAKE_BUILD_TYPE Debug Release CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release" FORCE )
MARK_AS_ADVANCED( CMAKE_BUILD_TYPE )
ENDIF ( NOT CMAKE_BUILD_TYPE )
# Package dependencies:
FIND_PACKAGE( GLEW REQUIRED )
IF (APPLE)
FIND_PACKAGE( wxWidgets REQUIRED COMPONENTS base core gl net xml adv )
FIND_PACKAGE( OPENGL REQUIRED )
SET( WXWIDGETS_USE_GL TRUE )
ELSE (APPLE)
IF (WIN32)
FIND_PACKAGE( wxWidgets REQUIRED COMPONENTS adv base core gl net xml )
FIND_PACKAGE( OPENGL REQUIRED )
ELSE (WIN32)
FIND_PACKAGE( wxWidgets REQUIRED )
ENDIF(WIN32)
ENDIF(APPLE)
# Includes:
INCLUDE_DIRECTORIES( ${GLEW_INCLUDE_PATH} )
INCLUDE( ${wxWidgets_USE_FILE} )
INCLUDE_DIRECTORIES( . ${wxWidgets_INCLUDE_DIRS} )
IF (UNIX AND NOT "${CMAKE_GENERATOR}" MATCHES Xcode)
ADD_DEFINITIONS( `${wxWidgets_CONFIG_EXECUTABLE} --cppflags` )
ENDIF (UNIX AND NOT "${CMAKE_GENERATOR}" MATCHES Xcode)
# This is needed because Xcode does not understand the "`" syntax to execute the wxconfig command.
# Therefore, when the projet was built, it failed because the command was not executed and only
# considered as a compiler flag, which was not understood.
IF("${CMAKE_GENERATOR}" MATCHES Xcode)
EXEC_PROGRAM( ${wxWidgets_CONFIG_EXECUTABLE} ARGS --cxxflags OUTPUT_VARIABLE CMAKE_WXWINDOWS_CXX_FLAGS )
ADD_DEFINITIONS(${CMAKE_WXWINDOWS_CXX_FLAGS})
ENDIF("${CMAKE_GENERATOR}" MATCHES Xcode)
# To shut up a few warnings on Visual Studio 9 MS deprecated C. This removes all 1.276E1265 security warnings. Copied for ITK CMakeList
if (WIN32)
ADD_DEFINITIONS(
-D_CRT_FAR_MAPPINGS_NO_DEPRECATE
-D_CRT_IS_WCTYPE_NO_DEPRECATE
-D_CRT_MANAGED_FP_NO_DEPRECATE
-D_CRT_NONSTDC_NO_DEPRECATE
-D_CRT_SECURE_NO_DEPRECATE
-D_CRT_SECURE_NO_DEPRECATE_GLOBALS
-D_CRT_SETERRORMODE_BEEP_SLEEP_NO_DEPRECATE
-D_CRT_TIME_FUNCTIONS_NO_DEPRECATE
-D_CRT_VCCLRIT_NO_DEPRECATE
-D_SCL_SECURE_NO_DEPRECATE
)
ENDIF (WIN32)
# Disables all geometry shader support from code when OpenGL version does not support it
# Presented as an advanced option to the user.
OPTION(USE_GEOMETRY_SHADERS "Compile and use geometry shaders" ON)
IF(USE_GEOMETRY_SHADERS)
ADD_DEFINITIONS( -D_COMPILE_GEO_SHADERS=1 )
ELSE(USE_GEOMETRY_SHADERS)
ADD_DEFINITIONS( -D_COMPILE_GEO_SHADERS=0 )
ENDIF(USE_GEOMETRY_SHADERS)
MARK_AS_ADVANCED( USE_GEOMETRY_SHADERS )
# Option to enable building a lightweight version of the
# GUI, without features that are not used by lots
# of users.
OPTION(BUILD_LIGHTWEIGHT_GUI "Build lightweight GUI" ON)
IF(BUILD_LIGHTWEIGHT_GUI)
ADD_DEFINITIONS( -D_USE_LIGHT_GUI=1 )
ELSE(BUILD_LIGHTWEIGHT_GUI)
ADD_DEFINITIONS( -D_USE_LIGHT_GUI=0 )
ENDIF(BUILD_LIGHTWEIGHT_GUI)
MARK_AS_ADVANCED( BUILD_LIGHTWEIGHT_GUI )
#hiding this for now
MARK_AS_ADVANCED( wxWidgets_wxrc_EXECUTABLE )
MARK_AS_ADVANCED( wxWidgets_USE_DEBUG )
IF(UNIX)
# Global compiler flags for LINUX:
#-----------------------
# -Wno-long-long since on Ubuntu 8.10 it won't compile without it
# -ansi force ISO-C++98 compliance (not GNU++98)
SET( CMAKE_CXX_FLAGS "-Wall -ansi -Wno-long-long" )
SET( CMAKE_CXX_FLAGS_DEBUG "-g -DDEBUG -O0" )
SET( CMAKE_CXX_FLAGS_RELEASE "-O3" )
SET( CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -DDEBUG -O2" )
ENDIF(UNIX)
# Add this define for every platform. Used by nifti_io to try to read .nii.gz files.
ADD_DEFINITIONS(
-DHAVE_ZLIB
)
SET( target "fibernavigator")
# Should do the same for header files so that they are included in the Visual Studio solution
file( GLOB GUI_HDR "gui/*.h" )
file( GLOB GFX_HDR "gfx/*.h" )
file( GLOB DS_HDR "dataset/*.h" )
file( GLOB MISC_HDR "misc/*.h" )
file( GLOB ALGORITHMS_HDR "misc/Algorithms/*.h" )
file( GLOB FANTOM_HDR "misc/Fantom/*.h" )
file( GLOB ISO_HDR "misc/IsoSurface/*.h" )
file( GLOB LIC_HDR "misc/lic/*.h" )
file( GLOB NIFTI_HDR "misc/nifti/*.h" )
file( GLOB GUI_SRC "gui/*.cpp" )
file( GLOB GFX_SRC "gfx/*.cpp" )
file( GLOB DS_SRC "dataset/*.cpp" )
file( GLOB MISC_SRC "misc/*.cpp" )
file( GLOB ALGORITHMS_SRC "misc/Algorithms/*.cpp" )
file( GLOB FANTOM_SRC "misc/Fantom/*.cpp" )
file( GLOB ISO_SRC "misc/IsoSurface/*.cpp" )
file( GLOB LIC_SRC "misc/lic/*.cpp" )
file( GLOB NIFTI_SRC "misc/nifti/*.c" )
IF( WIN32 )
ADD_EXECUTABLE( ${target} WIN32 main.h main.cpp Logger.h Logger.cpp
${ALGORITHMS_SRC} ${DS_SRC} ${GFX_SRC} ${GUI_SRC} ${FANTOM_SRC} ${ISO_SRC} ${LIC_SRC} ${MISC_SRC} ${NIFTI_SRC} ${VERSION_SRC}
${ALGORITHMS_HDR} ${DS_HDR} ${GFX_HDR} ${GUI_HDR} ${FANTOM_HDR} ${ISO_HDR} ${LIC_HDR} ${MISC_HDR} ${NIFTI_HDR} ${VERSION_HDR} )
ELSE( WIN32 )
ADD_EXECUTABLE( ${target} main.h main.cpp Logger.h Logger.cpp
${ALGORITHMS_SRC} ${DS_SRC} ${GFX_SRC} ${GUI_SRC} ${FANTOM_SRC} ${ISO_SRC} ${LIC_SRC} ${MISC_SRC} ${NIFTI_SRC} ${VERSION_SRC}
${ALGORITHMS_HDR} ${DS_HDR} ${GFX_HDR} ${GUI_HDR} ${FANTOM_HDR} ${ISO_HDR} ${LIC_HDR} ${MISC_HDR} ${NIFTI_HDR} ${VERSION_HDR} )
ENDIF( WIN32 )
IF( WIN32 )
FIND_FILE( GLEW_DLL_FOUND glew32.dll REQUIRED )
find_file( wxmsw28ud_adv_vc_custom_dll_found wxmsw28ud_adv_vc_custom.dll REQUIRED )
find_file( wxmsw28ud_core_vc_custom_dll_found wxmsw28ud_core_vc_custom.dll REQUIRED )
find_file( wxmsw28ud_gl_vc_custom_dll_found wxmsw28ud_gl_vc_custom.dll REQUIRED )
find_file( wxbase28ud_xml_vc_custom_dll_found wxbase28ud_xml_vc_custom.dll REQUIRED )
find_file( wxbase28ud_vc_custom_dll_found wxbase28ud_vc_custom.dll REQUIRED )
find_file( opengl_dll_found opengl32.dll REQUIRED )
find_file( glu_dll_found glu32.dll REQUIRED )
ENDIF( WIN32 )
IF (APPLE)
TARGET_LINK_LIBRARIES( ${target} ${GLEW_LIBRARY} ${OPENGL_LIBRARY} ${wxWidgets_LIBRARIES} z)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/icons ${CMAKE_BINARY_DIR}/bin/Contents/Resources/icons)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/GLSL ${CMAKE_BINARY_DIR}/bin/Contents/Resources/GLSL)
ELSE(APPLE)
IF(WIN32)
TARGET_LINK_LIBRARIES( ${target} ${GLEW_LIBRARY} ${OPENGL_LIBRARY} ${wxWidgets_LIBRARIES})
FOREACH(BUILD_TYPE ${CMAKE_BUILD_TYPE})
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/GLSL ${CMAKE_BINARY_DIR}/bin/${BUILD_TYPE}/GLSL )
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/icons ${CMAKE_BINARY_DIR}/bin/${BUILD_TYPE}/icons )
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${GLEW_DLL_FOUND} ${CMAKE_BINARY_DIR}/bin/${BUILD_TYPE}/)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${wxmsw28ud_adv_vc_custom_dll_found} ${CMAKE_BINARY_DIR}/bin/${BUILD_TYPE}/)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${wxmsw28ud_core_vc_custom_dll_found} ${CMAKE_BINARY_DIR}/bin/${BUILD_TYPE}/)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${wxmsw28ud_gl_vc_custom_dll_found} ${CMAKE_BINARY_DIR}/bin/${BUILD_TYPE}/)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${wxbase28ud_xml_vc_custom_dll_found} ${CMAKE_BINARY_DIR}/bin/${BUILD_TYPE}/)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${wxbase28ud_vc_custom_dll_found} ${CMAKE_BINARY_DIR}/bin/${BUILD_TYPE}/)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${opengl_dll_found} ${CMAKE_BINARY_DIR}/bin/${BUILD_TYPE}/)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${glu_dll_found} ${CMAKE_BINARY_DIR}/bin/${BUILD_TYPE}/)
# For the VisualStudio solution, copy the shaders at the root of the project so that the shaders are found when 'F5' is ran
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/GLSL ${CMAKE_BINARY_DIR}/bin/${BUILD_TYPE}/GLSL)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/icons ${CMAKE_BINARY_DIR}/bin/${BUILD_TYPE}/icons)
ENDFOREACH(BUILD_TYPE ${CMAKE_BUILD_TYPE})
ELSE(WIN32)
TARGET_LINK_LIBRARIES( ${target} ${GLEW_LIBRARY} ${wxWidgets_LIBRARIES} wx_gtk2u_gl-3.0 libGL.so libz.so libGLU.so )
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/GLSL ${CMAKE_BINARY_DIR}/bin/GLSL)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/icons ${CMAKE_BINARY_DIR}/bin/icons)
ENDIF(WIN32)
ENDIF(APPLE)