]> Creatis software - clitk.git/blob - vv/CMakeLists.txt
Merge branch 'VTK6_Qt5' into VTK6_Qt5_LineProfile
[clitk.git] / vv / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.4)
2
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 #=========================================================
10
11
12 #=========================================================
13 #List of vv tools to compile
14 set(vv_TOOLS
15   vvToolMedianFilter
16   vvToolRigidReg
17   vvToolCropImage
18   vvToolBinarize
19   vvToolImageArithm
20   vvToolResample
21   vvToolMIP
22   vvToolConvert ## with dummy vvToolConvert.ui
23   vvToolROIManager
24   vvToolSegmentation
25   vvToolProfile
26   ## these ones are for tests (not working)
27   # vvToolTest
28   # vvToolFoo
29   # vvToolFooWithWidgetBase
30   # vvToolPlastimatch
31   # vvToolConnectedComponentLabeling
32   ## these ones are old ones
33   # vvToolExtractPatient
34   # vvToolExtractLung
35   # vvToolStructureSetManager
36 )
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)
51
52 #=========================================================
53 # List of vv source files
54
55 # in COMMON_WITH_UI -> must have .h and .cxx and .ui
56 set(vv_COMMON_WITH_UI
57   vvInfoPanel
58   vvMainWindow
59   vvLinkPanel
60   vvOverlayPanel
61   vvLandmarksPanel
62   vvProgressDialog
63   vvSegmentationDialog
64   vvSurfaceViewerDialog
65   vvDeformationDialog
66   vvStructSelector
67   vvIntensityValueSlider
68   vvLabelImageLoaderWidget
69   vvToolWidgetBase
70   vvToolSimpleInputSelectorWidget
71   vvToolInputSelectorWidget
72   vvRegisterForm
73 )
74
75 # All others sources
76 set(vv_SRCS
77   vvQProgressDialogITKCommand.cxx
78   vvQDicomSeriesSelector.cxx
79   QTreePushButton.cxx
80   vvMainWindowBase.cxx
81   vvImageWarp.cxx
82   vvDeformableRegistration.cxx
83   vtkVOXImageWriter.cxx
84   vvInteractorStyleNavigator.cxx
85   vvSlicer.cxx
86   vvLandmarks.cxx
87   vvLandmarksGlyph.cxx
88   vvClipPolyData.cxx
89   vvGlyphSource.cxx
90   vvGlyph2D.cxx
91   vvSlicerManager.cxx
92   vvSlicerManagerCommand.cxx
93   vvUtils.cxx
94 #  vvMaximumIntensityProjection.cxx
95   vvMesh.cxx
96   vvMeshActor.cxx
97   vvMeshReader.cxx
98   vvMidPosition.cxx
99   vvImageContour.cxx
100   vvBinaryImageOverlayActor.cxx
101   vvStructureSetActor.cxx
102   vvSaveState.cxx
103   vvReadState.cxx
104   vvROIActor.cxx
105   vvBlendImageActor.cxx
106   vvToolManager.cxx
107   vvToolCreatorBase.cxx
108   vvToolBaseBase.cxx
109 )
110
111 #=========================================================
112 # Qt related commands
113 if(vv_QT_VERSION VERSION_GREATER "4")
114 find_package(Qt5Widgets REQUIRED)
115 find_package(Qt5Network REQUIRED)
116 find_package(Qt5Designer REQUIRED)
117 link_directories(${QT5Widgets_LIBRARIES})
118 link_directories(${QT5Network_LIBRARIES})
119 link_directories(${QT5Designer_LIBRARIES})
120
121 qt5_wrap_cpp(vv_SRCS
122   vvMainWindowBase.h
123   QTreePushButton.h
124   vvDocumentation.h
125   vvHelpDialog.h
126   vvQDicomSeriesSelector.h
127   vvSlicerManager.h
128   vvSlicer.h
129   vvStructureSetActor.h
130   vvROIActor.h
131   vvToolCreatorBase.h
132   )
133
134 qt5_wrap_ui(vv_UI_CXX
135   qt_ui/vvHelpDialog.ui
136   qt_ui/vvDocumentation.ui
137   qt_ui/vvDicomSeriesSelector.ui
138   qt_ui/vvDummyWindow.ui #For testing
139   )
140
141 QT5_add_resources(vv_SRCS vvIcons.qrc)
142
143 # Add the autotools in the header vvToolsList.h for initialization of the dummy
144 # variables in vv.cxx for the tools contained in vvLib
145 if(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt IS_NEWER_THAN ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h)
146   file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h)
147   foreach(tool ${vv_TOOLS})
148     file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h "#include \"${tool}.h\"\n")
149     file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h "extern const vvToolCreator<${tool}> *dummy${tool};\n")
150     file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h "const vvToolCreator<${tool}> *dummy${tool}2 = dummy${tool};\n\n")
151   endforeach(tool)
152 endif(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt IS_NEWER_THAN ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h)
153
154 # Add the autotools and the common files ui
155 foreach(tool ${vv_TOOLS} ${vv_COMMON_WITH_UI})
156     set(vv_SRCS ${vv_SRCS} ${tool}.cxx)
157     QT5_WRAP_CPP(vv_SRCS ${tool}.h)
158     QT5_WRAP_UI(vv_UI_CXX qt_ui/${tool}.ui)
159 endforeach(tool)
160
161 # Add the common source files
162 foreach(tool ${vv_COMMON})
163     set(vv_SRCS ${vv_SRCS} ${tool}.cxx)
164     QT5_WRAP_CPP(vv_SRCS ${tool}.h)
165 endforeach(tool)
166
167 # if Windows and Qt was built as a static lib then don't set QT_DLL flag
168 set(QT_STATIC 0)
169 if(WIN32)
170   if(EXISTS ${Qt5Widgets_LIBRARIES}/QtCore.prl)
171     file(READ ${Qt5Widgets_LIBRARIES}/QtCore.prl QT_CORE_PRL)
172     if(${QT_CORE_PRL} MATCHES "static")
173       set(QT_STATIC 1)
174     endif(${QT_CORE_PRL} MATCHES "static")
175   endif(EXISTS ${Qt5Widgets_LIBRARIES}/QtCore.prl)
176 endif(WIN32)
177 if(NOT QT_STATIC)
178   add_definitions(-DQT_DLL)
179 endif(NOT QT_STATIC)
180
181 add_definitions(-DQT_THREAD_SUPPORT)
182
183 include_directories(
184   ${Qt5Widgets_INCLUDE_DIRS}
185   ${Qt5GUI_INCLUDE_DIRS}
186   ${Qt5CORE_INCLUDE_DIRS}
187   ${Qt5Network_INCLUDE_DIRS}
188   ${Qt5Designer_INCLUDE_DIRS}
189   ${CMAKE_CURRENT_BINARY_DIR}
190   ${CMAKE_CURRENT_SOURCE_DIR}
191 )
192 else()
193 find_package(Qt4 REQUIRED)
194 link_directories(${QT_LIBRARY_DIR})
195
196
197 QT4_WRAP_CPP(vv_SRCS
198   vvMainWindowBase.h
199   QTreePushButton.h
200   vvDocumentation.h
201   vvHelpDialog.h
202   vvQDicomSeriesSelector.h
203   vvSlicerManager.h
204   vvStructureSetActor.h
205   vvROIActor.h
206   vvToolCreatorBase.h
207   )
208
209 QT4_WRAP_UI(vv_UI_CXX
210   qt_ui/vvHelpDialog.ui
211   qt_ui/vvDocumentation.ui
212   qt_ui/vvDicomSeriesSelector.ui
213   qt_ui/vvDummyWindow.ui #For testing
214   )
215
216 QT4_ADD_RESOURCES(vv_SRCS vvIcons.qrc)
217
218 # Add the autotools in the header vvToolsList.h for initialization of the dummy
219 # variables in vv.cxx for the tools contained in vvLib
220 if(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt IS_NEWER_THAN ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h)
221   file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h)
222   foreach(tool ${vv_TOOLS})
223     file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h "#include \"${tool}.h\"\n")
224     file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h "extern const vvToolCreator<${tool}> *dummy${tool};\n")
225     file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h "const vvToolCreator<${tool}> *dummy${tool}2 = dummy${tool};\n\n")
226   endforeach(tool)
227 endif(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt IS_NEWER_THAN ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h)
228
229 # Add the autotools and the common files ui
230 foreach(tool ${vv_TOOLS} ${vv_COMMON_WITH_UI})
231     set(vv_SRCS ${vv_SRCS} ${tool}.cxx)
232     QT4_WRAP_CPP(vv_SRCS ${tool}.h)
233     QT4_WRAP_UI(vv_UI_CXX qt_ui/${tool}.ui)
234 endforeach(tool)
235
236 # Add the common source files
237 foreach(tool ${vv_COMMON})
238     set(vv_SRCS ${vv_SRCS} ${tool}.cxx)
239     QT4_WRAP_CPP(vv_SRCS ${tool}.h)
240 endforeach(tool)
241
242 # if Windows and Qt was built as a static lib then don't set QT_DLL flag
243 set(QT_STATIC 0)
244 if(WIN32)
245   if(EXISTS ${QT_LIBRARY_DIR}/QtCore.prl)
246     file(READ ${QT_LIBRARY_DIR}/QtCore.prl QT_CORE_PRL)
247     if(${QT_CORE_PRL} MATCHES "static")
248       set(QT_STATIC 1)
249     endif(${QT_CORE_PRL} MATCHES "static")
250   endif(EXISTS ${QT_LIBRARY_DIR}/QtCore.prl)
251 endif(WIN32)
252 if(NOT QT_STATIC)
253   add_definitions(-DQT_DLL)
254 endif(NOT QT_STATIC)
255
256 add_definitions(-DQT_THREAD_SUPPORT)
257
258 include_directories(
259   ${QT_INCLUDES}
260   ${QT_INCLUDE_DIR}
261   ${QT_QTGUI_INCLUDE_DIR}
262   ${QT_QTCORE_INCLUDE_DIR}
263   ${CMAKE_CURRENT_BINARY_DIR}
264   ${CMAKE_CURRENT_SOURCE_DIR}
265 )
266 endif()
267 #=========================================================
268
269 #=========================================================
270 #support for parallel deformable registration with OpenMP
271 if(NOT APPLE)
272 if(CMAKE_COMPILER_IS_GNUCC)
273   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
274 endif(CMAKE_COMPILER_IS_GNUCC)
275 endif(NOT APPLE)
276 #=========================================================
277
278 #=========================================================
279 include_directories(
280   ../common
281   ../tools
282   ../segmentation
283   )
284
285 #=========================================================
286 #Add each tool's dependencies
287 foreach(tool ${vv_TOOLS})
288   set(toolLibs ${toolLibs} ${${tool}_LIBS})
289 endforeach(tool)
290
291 #=========================================================
292 #Add Foundation Libraries (this should be after our libraries, since we depend
293 #on them)
294 if(vv_QT_VERSION VERSION_GREATER "4")
295 set(foundationLibraries clitkCommon ${ITK_LIBRARIES} ${VTK_LIBRARIES})
296 else()
297 set(foundationLibraries clitkCommon ${ITK_LIBRARIES} QVTK vtkHybrid)
298 endif()
299
300 #=========================================================
301 # Use CxImage to create animated gifs
302 if(CLITK_EXPERIMENTAL)
303   set(vvCxImage clitkCxImage)
304   set(vv_SRCS ${vv_SRCS} vvAnimatedGIFWriter.cxx)
305   include_directories(${CLITK_SOURCE_DIR}/utilities/CxImage)
306   add_subdirectory(${CLITK_SOURCE_DIR}/utilities/CxImage ${PROJECT_BINARY_DIR}/utilities/CxImage)
307 endif(CLITK_EXPERIMENTAL)
308 #=========================================================
309
310 #-----------------------------------------------------------------------------
311 # Avoid linker bug in Mac OS 10.5
312 # See http://wiki.finkproject.org/index.php/Fink:Packaging:Preparing_for_10.5#OpenGL_Bug
313 #
314 if(APPLE)
315   find_library(CoreFoundation_LIBRARY CoreFoundation REQUIRED)
316   find_library(ApplicationServices_LIBRARY ApplicationServices REQUIRED)
317   find_library(SystemConfiguration_LIBRARY SystemConfiguration REQUIRED)
318   find_library(Security_LIBRARY Security REQUIRED)
319   set(APPLE_FRAMEWORKS ${CoreFoundation_LIBRARY}
320     ${ApplicationServices_LIBRARY}
321     ${SystemConfiguration_LIBRARY}
322     ${Security_LIBRARY}
323     )
324   message(STATUS "===== ${APPLE_FRAMEWORKS}")
325 endif()
326 #=========================================================
327 #Create binary and libs for tests
328 if(vv_QT_VERSION VERSION_GREATER "4")
329 set(vvExternalLibs clitkSegmentationGgoLib ${toolLibs} ${foundationLibraries} ${vvCxImage} Qt5::Widgets Qt5::Network Qt5::Designer ${APPLE_FRAMEWORKS})
330 else()
331 set(vvExternalLibs clitkSegmentationGgoLib ${toolLibs} ${foundationLibraries} ${vvCxImage} ${QT_LIBRARIES} ${QT_QTNETWORK_LIBRARY} ${APPLE_FRAMEWORKS})
332 endif()
333 # QtNetwork is required by vvRegisterForm
334
335 add_library(vvLib ${vv_SRCS} ${vv_UI_CXX})
336 target_link_libraries(vvLib ${vvExternalLibs})
337
338 if(WIN32)
339   add_executable(vv WIN32 vv.cxx vvIcon.rc)
340 else(WIN32)
341   add_executable(vv vv.cxx)
342 endif(WIN32)
343
344 target_link_libraries(vv vvLib)
345
346 #=========================================================
347 # Install options (also used by CPack)
348 install(TARGETS vv DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE)
349
350 #=========================================================
351
352 #=========================================================
353 # CPack options
354 set(CPACK_PACKAGE_NAME "vv")
355 set(CPACK_SOURCE_PACKAGE_FILE_NAME "vv-src")
356 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "vv, the 4D slicer : let's jump into a new dimension !")
357 set(CPACK_PACKAGE_VENDOR "Creatis-CLB")
358 set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/ReadMe.txt")
359 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt")
360 set(CPACK_PACKAGE_VERSION_MAJOR "1")
361 set(CPACK_PACKAGE_VERSION_MINOR "3")
362 set(CPACK_PACKAGE_VERSION_PATCH "0")
363 if(NIGHTLY)
364   set(CPACK_PACKAGE_INSTALL_DIRECTORY "vv-nightly")
365 else(NIGHTLY)
366   set(CPACK_PACKAGE_INSTALL_DIRECTORY "vv")
367 endif(NIGHTLY)
368 set(CPACK_STRIP_FILES TRUE)
369
370 if(WIN32)
371   # There is a bug in NSI that does not handle full unix paths properly. Make
372   # sure there is at least one set of four (4) backlasshes.
373   set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\icons\\\\ducky.ico")
374   set(CPACK_NSIS_INSTALLED_ICON_NAME "vv.exe")
375 if(NIGHTLY)
376   set(CPACK_NSIS_DISPLAY_NAME "vv - The 4D slicer (nightly)")
377 else(NIGHTLY)
378   set(CPACK_NSIS_DISPLAY_NAME "vv - The 4D slicer")
379 endif(NIGHTLY)
380   set(CPACK_NSIS_HELP_LINK "http://www.creatis.insa-lyon.fr/rio/vv")
381   set(CPACK_NSIS_URL_INFO_ABOUT "http://www.creatis.insa-lyon.fr/rio")
382   set(CPACK_NSIS_CONTACT "vv@creatis.insa-lyon.fr")
383   set(CPACK_NSIS_CREATE_ICONS_EXTRA "CreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\vv.lnk\\\" \\\"$INSTDIR\\\\bin\\\\vv.exe\\\" ")
384   set(CPACK_NSIS_DELETE_ICONS_EXTRA "Delete \\\"$SMPROGRAMS\\\\$MUI_TEMP\\\\vv.lnk\\\" ")
385   #set(CPACK_NSIS_MODIFY_PATH ON) SR: buggy, wait for cmake updates for a fix
386   #set(CPACK_BINARY_ZIP ON)
387 else(WIN32)
388   set(CPACK_GENERATOR "STGZ")
389   set(CPACK_SOURCE_GENERATOR "TGZ")
390 endif(WIN32)
391 include(CPack)
392 #=========================================================
393 #=========================================================
394 configure_file(vvConfiguration.h.in vvConfiguration.h)
395 #=========================================================