1 cmake_minimum_required(VERSION 2.4)
3 #=========================================================
4 # To avoid warning with some version
5 if(COMMAND cmake_policy)
6 cmake_policy(SET CMP0003 NEW)
7 cmake_policy(SET CMP0007 NEW)
8 endif(COMMAND cmake_policy)
9 #=========================================================
12 #=========================================================
13 #List of vv tools to compile
22 vvToolConvert ## with dummy vvToolConvert.ui
26 ## these ones are for tests (not working)
29 # vvToolFooWithWidgetBase
31 # vvToolConnectedComponentLabeling
32 ## these ones are old ones
33 # vvToolExtractPatient
35 # vvToolStructureSetManager
37 # dependencies of the tools
38 # Future issues : when tool depend on other tools ... how to manage that ?
39 # >> add the relevant $_LIBS variable to the tool that has dependencies?
40 set(vvToolBinarize_LIBS clitkBinarizeImageLib)
41 set(vvToolProfile_LIBS clitkProfileImageLib)
42 set(vvToolResample_LIBS clitkResampleImageLib)
43 set(vvToolConvert_LIBS clitkImageConvertLib)
44 set(vvToolExtractPatient_LIBS clitkSegmentationGgoLib)
45 set(vvToolExtractLung_LIBS clitkSegmentationGgoLib)
46 set(vvToolCropImage_LIBS clitkCropImageLib)
47 set(vvToolMIP_LIBS clitkMIPLib)
48 set(vvToolMedianFilter_LIBS clitkMedianImageFilterLib)
49 set(vvToolImageArithm_LIBS clitkImageArithmImageLib)
50 set(vvToolROIManager_LIBS clitkDicomRTStruct)
52 #=========================================================
53 # List of vv source files
55 # in COMMON_WITH_UI -> must have .h and .cxx and .ui
67 vvIntensityValueSlider
68 vvLabelImageLoaderWidget
70 vvToolSimpleInputSelectorWidget
71 vvToolInputSelectorWidget
77 vvQProgressDialogITKCommand.cxx
78 vvQDicomSeriesSelector.cxx
82 vvDeformableRegistration.cxx
84 vvInteractorStyleNavigator.cxx
92 vvSlicerManagerCommand.cxx
94 # vvMaximumIntensityProjection.cxx
100 vvBinaryImageOverlayActor.cxx
101 vvStructureSetActor.cxx
105 vvBlendImageActor.cxx
107 vvToolCreatorBase.cxx
111 #=========================================================
112 # Qt related commands
114 if(vv_QT_VERSION VERSION_GREATER "4")
115 find_package(Qt5Widgets REQUIRED)
116 find_package(Qt5Network REQUIRED)
117 find_package(Qt5Designer REQUIRED)
119 find_package(Qt4 REQUIRED)
122 if(vv_QT_VERSION VERSION_GREATER "4")
123 link_directories(${QT5Widgets_LIBRARIES})
124 link_directories(${QT5Network_LIBRARIES})
125 link_directories(${QT5Designer_LIBRARIES})
127 link_directories(${QT_LIBRARY_DIR})
130 if(vv_QT_VERSION VERSION_GREATER "4")
136 vvQDicomSeriesSelector.h
139 vvStructureSetActor.h
149 vvQDicomSeriesSelector.h
152 vvStructureSetActor.h
158 if(vv_QT_VERSION VERSION_GREATER "4")
159 qt5_wrap_ui(vv_UI_CXX
160 qt_ui/vvHelpDialog.ui
161 qt_ui/vvDocumentation.ui
162 qt_ui/vvDicomSeriesSelector.ui
163 qt_ui/vvDummyWindow.ui #For testing
166 QT4_WRAP_UI(vv_UI_CXX
167 qt_ui/vvHelpDialog.ui
168 qt_ui/vvDocumentation.ui
169 qt_ui/vvDicomSeriesSelector.ui
170 qt_ui/vvDummyWindow.ui #For testing
174 if(vv_QT_VERSION VERSION_GREATER "4")
175 QT5_add_resources(vv_SRCS vvIcons.qrc)
177 QT4_ADD_RESOURCES(vv_SRCS vvIcons.qrc)
180 # Add the autotools in the header vvToolsList.h for initialization of the dummy
181 # variables in vv.cxx for the tools contained in vvLib
182 if(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt IS_NEWER_THAN ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h)
183 file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h)
184 foreach(tool ${vv_TOOLS})
185 file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h "#include \"${tool}.h\"\n")
186 file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h "extern const vvToolCreator<${tool}> *dummy${tool};\n")
187 file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h "const vvToolCreator<${tool}> *dummy${tool}2 = dummy${tool};\n\n")
189 endif(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt IS_NEWER_THAN ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h)
191 # Add the autotools and the common files ui
192 foreach(tool ${vv_TOOLS} ${vv_COMMON_WITH_UI})
193 set(vv_SRCS ${vv_SRCS} ${tool}.cxx)
194 if(vv_QT_VERSION VERSION_GREATER "4")
195 QT5_WRAP_CPP(vv_SRCS ${tool}.h)
196 QT5_WRAP_UI(vv_UI_CXX qt_ui/${tool}.ui)
198 QT4_WRAP_CPP(vv_SRCS ${tool}.h)
199 QT4_WRAP_UI(vv_UI_CXX qt_ui/${tool}.ui)
203 # Add the common source files
204 foreach(tool ${vv_COMMON})
205 set(vv_SRCS ${vv_SRCS} ${tool}.cxx)
206 if(vv_QT_VERSION VERSION_GREATER "4")
207 QT5_WRAP_CPP(vv_SRCS ${tool}.h)
209 QT4_WRAP_CPP(vv_SRCS ${tool}.h)
213 # if Windows and Qt was built as a static lib then don't set QT_DLL flag
216 if(vv_QT_VERSION VERSION_GREATER "4")
217 if(EXISTS ${Qt5Widgets_LIBRARIES}/QtCore.prl)
218 file(READ ${Qt5Widgets_LIBRARIES}/QtCore.prl QT_CORE_PRL)
219 if(${QT_CORE_PRL} MATCHES "static")
221 endif(${QT_CORE_PRL} MATCHES "static")
222 endif(EXISTS ${Qt5Widgets_LIBRARIES}/QtCore.prl)
224 if(EXISTS ${QT_LIBRARY_DIR}/QtCore.prl)
225 file(READ ${QT_LIBRARY_DIR}/QtCore.prl QT_CORE_PRL)
226 if(${QT_CORE_PRL} MATCHES "static")
228 endif(${QT_CORE_PRL} MATCHES "static")
229 endif(EXISTS ${QT_LIBRARY_DIR}/QtCore.prl)
233 add_definitions(-DQT_DLL)
236 add_definitions(-DQT_THREAD_SUPPORT)
237 if(vv_QT_VERSION VERSION_GREATER "4")
239 ${Qt5Widgets_INCLUDE_DIRS}
240 ${Qt5Gui_INCLUDE_DIRS}
241 ${Qt5Core_INCLUDE_DIRS}
242 ${Qt5Network_INCLUDE_DIRS}
243 ${Qt5Designer_INCLUDE_DIRS}
244 ${CMAKE_CURRENT_BINARY_DIR}
245 ${CMAKE_CURRENT_SOURCE_DIR}
251 ${QT_QTGUI_INCLUDE_DIR}
252 ${QT_QTCORE_INCLUDE_DIR}
253 ${CMAKE_CURRENT_BINARY_DIR}
254 ${CMAKE_CURRENT_SOURCE_DIR}
257 #=========================================================
259 #=========================================================
260 #support for parallel deformable registration with OpenMP
262 if(CMAKE_COMPILER_IS_GNUCC)
263 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
264 endif(CMAKE_COMPILER_IS_GNUCC)
266 #=========================================================
268 #=========================================================
275 #=========================================================
276 #Add each tool's dependencies
277 foreach(tool ${vv_TOOLS})
278 set(toolLibs ${toolLibs} ${${tool}_LIBS})
281 #=========================================================
282 #Add Foundation Libraries (this should be after our libraries, since we depend
284 if(VTK_VERSION VERSION_GREATER "6.2.0")
285 set(foundationLibraries clitkCommon ${ITK_LIBRARIES} ${VTK_LIBRARIES})
287 set(foundationLibraries clitkCommon ${ITK_LIBRARIES} QVTK vtkHybrid)
290 #=========================================================
291 # Use CxImage to create animated gifs
292 if(CLITK_EXPERIMENTAL)
293 set(vvCxImage clitkCxImage)
294 set(vv_SRCS ${vv_SRCS} vvAnimatedGIFWriter.cxx)
295 include_directories(${CLITK_SOURCE_DIR}/utilities/CxImage)
296 add_subdirectory(${CLITK_SOURCE_DIR}/utilities/CxImage ${PROJECT_BINARY_DIR}/utilities/CxImage)
297 endif(CLITK_EXPERIMENTAL)
298 #=========================================================
300 #-----------------------------------------------------------------------------
301 # Avoid linker bug in Mac OS 10.5
302 # See http://wiki.finkproject.org/index.php/Fink:Packaging:Preparing_for_10.5#OpenGL_Bug
305 find_library(CoreFoundation_LIBRARY CoreFoundation REQUIRED)
306 find_library(ApplicationServices_LIBRARY ApplicationServices REQUIRED)
307 find_library(SystemConfiguration_LIBRARY SystemConfiguration REQUIRED)
308 find_library(Security_LIBRARY Security REQUIRED)
309 set(APPLE_FRAMEWORKS ${CoreFoundation_LIBRARY}
310 ${ApplicationServices_LIBRARY}
311 ${SystemConfiguration_LIBRARY}
314 message(STATUS "===== ${APPLE_FRAMEWORKS}")
316 #=========================================================
317 #Create binary and libs for tests
318 if(vv_QT_VERSION VERSION_GREATER "4")
319 set(vvExternalLibs clitkSegmentationGgoLib ${toolLibs} ${foundationLibraries} ${vvCxImage} Qt5::Widgets Qt5::Network Qt5::Designer ${APPLE_FRAMEWORKS})
321 set(vvExternalLibs clitkSegmentationGgoLib ${toolLibs} ${foundationLibraries} ${vvCxImage} ${QT_LIBRARIES} ${APPLE_FRAMEWORKS})
323 # QtNetwork is required by vvRegisterForm ${QT_QTNETWORK_LIBRARY}
325 #-----------------------------------------------------------------------------
326 # For retina displays, see
327 # http://public.kitware.com/pipermail/vtkusers/2015-February/090117.html
329 set(vv_SRCS ${vv_SRCS} vvOSXHelper.mm)
332 add_library(vvLib ${vv_SRCS} ${vv_UI_CXX})
333 target_link_libraries(vvLib ${vvExternalLibs})
336 add_executable(vv WIN32 vv.cxx vvIcon.rc)
338 add_executable(vv vv.cxx)
341 target_link_libraries(vv vvLib)
343 #=========================================================
344 # Install options (also used by CPack)
345 install(TARGETS vv DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE)
347 #=========================================================
349 #=========================================================
351 set(CPACK_PACKAGE_NAME "vv")
352 set(CPACK_SOURCE_PACKAGE_FILE_NAME "vv-src")
353 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "vv, the 4D slicer : let's jump into a new dimension !")
354 set(CPACK_PACKAGE_VENDOR "Creatis-CLB")
355 set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/ReadMe.txt")
356 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt")
357 set(CPACK_PACKAGE_VERSION_MAJOR "1")
358 set(CPACK_PACKAGE_VERSION_MINOR "3")
359 set(CPACK_PACKAGE_VERSION_PATCH "0")
361 set(CPACK_PACKAGE_INSTALL_DIRECTORY "vv-nightly")
363 set(CPACK_PACKAGE_INSTALL_DIRECTORY "vv")
365 set(CPACK_STRIP_FILES TRUE)
368 # There is a bug in NSI that does not handle full unix paths properly. Make
369 # sure there is at least one set of four (4) backlasshes.
370 set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\icons\\\\ducky.ico")
371 set(CPACK_NSIS_INSTALLED_ICON_NAME "vv.exe")
373 set(CPACK_NSIS_DISPLAY_NAME "vv - The 4D slicer (nightly)")
375 set(CPACK_NSIS_DISPLAY_NAME "vv - The 4D slicer")
377 set(CPACK_NSIS_HELP_LINK "http://www.creatis.insa-lyon.fr/rio/vv")
378 set(CPACK_NSIS_URL_INFO_ABOUT "http://www.creatis.insa-lyon.fr/rio")
379 set(CPACK_NSIS_CONTACT "vv@creatis.insa-lyon.fr")
380 set(CPACK_NSIS_CREATE_ICONS_EXTRA "CreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\vv.lnk\\\" \\\"$INSTDIR\\\\bin\\\\vv.exe\\\" ")
381 set(CPACK_NSIS_DELETE_ICONS_EXTRA "Delete \\\"$SMPROGRAMS\\\\$MUI_TEMP\\\\vv.lnk\\\" ")
382 #set(CPACK_NSIS_MODIFY_PATH ON) SR: buggy, wait for cmake updates for a fix
383 #set(CPACK_BINARY_ZIP ON)
385 set(CPACK_GENERATOR "STGZ")
386 set(CPACK_SOURCE_GENERATOR "TGZ")
389 #=========================================================
390 #=========================================================
391 configure_file(vvConfiguration.h.in vvConfiguration.h)
392 #=========================================================