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