X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FCMakeLists.txt;h=107fdefd4f91412de42156ebb29fe3c7c228d8ab;hb=01d304e57910a247ec738631ba07ff93fd2ad2eb;hp=df4081e5883ac1f69f813e40d278065651842b5d;hpb=d4377ec80fd4e6f0156bb0673bb661acbf5b8cec;p=clitk.git diff --git a/vv/CMakeLists.txt b/vv/CMakeLists.txt index df4081e..107fdef 100644 --- a/vv/CMakeLists.txt +++ b/vv/CMakeLists.txt @@ -4,11 +4,17 @@ cmake_minimum_required(VERSION 2.4) # To avoid warning with some version if(COMMAND cmake_policy) cmake_policy(SET CMP0003 NEW) + cmake_policy(SET CMP0007 NEW) endif(COMMAND cmake_policy) #========================================================= +OPTION(CLITK_USE_PACS_CONNECTION "USE PACS CONNECTION" OFF) +#========================================================= +# Look for OpenGL2 version +if (VTK_RENDERING_BACKEND STREQUAL "OpenGL2") + add_definitions(-DVTK_OPENGL2) +endif () -#========================================================= #List of vv tools to compile set(vv_TOOLS vvToolMedianFilter @@ -16,12 +22,12 @@ set(vv_TOOLS vvToolCropImage vvToolBinarize vvToolImageArithm - vvToolResample vvToolMIP vvToolConvert ## with dummy vvToolConvert.ui vvToolROIManager vvToolSegmentation ## these ones are for tests (not working) + # vvToolTest # vvToolFoo # vvToolFooWithWidgetBase # vvToolPlastimatch @@ -31,11 +37,18 @@ set(vv_TOOLS # vvToolExtractLung # vvToolStructureSetManager ) +#List of vv tools to compile +#Ensure compatibility with QVTKOpenGL for VTK < v8.1 and QVTKOpenGLNativeWidget for others +set(vv_TOOLS_VTK7 + vvToolProfile + vvToolHistogram +) # dependencies of the tools # Future issues : when tool depend on other tools ... how to manage that ? # >> add the relevant $_LIBS variable to the tool that has dependencies? set(vvToolBinarize_LIBS clitkBinarizeImageLib) -set(vvToolResample_LIBS clitkResampleImageLib) +set(vvToolProfile_LIBS clitkProfileImageLib) +set(vvToolHistogram_LIBS clitkHistogramImageLib) set(vvToolConvert_LIBS clitkImageConvertLib) set(vvToolExtractPatient_LIBS clitkSegmentationGgoLib) set(vvToolExtractLung_LIBS clitkSegmentationGgoLib) @@ -56,8 +69,6 @@ set(vv_COMMON_WITH_UI vvOverlayPanel vvLandmarksPanel vvProgressDialog - vvSegmentationDialog - vvSurfaceViewerDialog vvDeformationDialog vvStructSelector vvIntensityValueSlider @@ -67,6 +78,13 @@ set(vv_COMMON_WITH_UI vvToolInputSelectorWidget vvRegisterForm ) +# in COMMON_WITH_UI -> must have .h and .cxx and VTK7.ui +#Ensure compatibility with QVTKOpenGL for VTK < v8.1 and QVTKOpenGLNativeWidget for others +set(vv_COMMON_WITH_UI_VTK7 + vvMainWindow + vvSegmentationDialog + vvSurfaceViewerDialog +) # All others sources set(vv_SRCS @@ -86,9 +104,10 @@ set(vv_SRCS vvGlyph2D.cxx vvSlicerManager.cxx vvSlicerManagerCommand.cxx + vvToolHistogramCommand.cxx vvUtils.cxx -# vvMaximumIntensityProjection.cxx - vvMesh.cxx +# vvMaximumIntensityProjection.cxx + vvMesh.cxx vvMeshActor.cxx vvMeshReader.cxx vvMidPosition.cxx @@ -106,79 +125,193 @@ set(vv_SRCS #========================================================= # Qt related commands -find_package(Qt4 REQUIRED) -link_directories(${QT_LIBRARY_DIR}) +if(vv_QT_VERSION VERSION_GREATER "4") + find_package(Qt5Widgets REQUIRED) + find_package(Qt5Network REQUIRED) + find_package(Qt5Designer REQUIRED) +else() + find_package(Qt4 REQUIRED) +endif() +if(vv_QT_VERSION VERSION_GREATER "4") + link_directories(${QT5Widgets_LIBRARIES}) + link_directories(${QT5Network_LIBRARIES}) + link_directories(${QT5Designer_LIBRARIES}) +else() + link_directories(${QT_LIBRARY_DIR}) +endif() -QT4_WRAP_CPP(vv_SRCS - vvMainWindowBase.h - QTreePushButton.h - vvDocumentation.h - vvHelpDialog.h - vvQDicomSeriesSelector.h - vvSlicerManager.h - vvStructureSetActor.h - vvROIActor.h - vvToolCreatorBase.h - ) +if(vv_QT_VERSION VERSION_GREATER "4") + qt5_wrap_cpp(vv_SRCS + vvMainWindowBase.h + QTreePushButton.h + vvDocumentation.h + vvHelpDialog.h + vvQDicomSeriesSelector.h + vvSlicerManager.h + vvSlicer.h + vvStructureSetActor.h + vvROIActor.h + vvToolCreatorBase.h + ) +else() + QT4_WRAP_CPP(vv_SRCS + vvMainWindowBase.h + QTreePushButton.h + vvDocumentation.h + vvHelpDialog.h + vvQDicomSeriesSelector.h + vvSlicerManager.h + vvSlicer.h + vvStructureSetActor.h + vvROIActor.h + vvToolCreatorBase.h + ) +endif() -QT4_WRAP_UI(vv_UI_CXX - qt_ui/vvHelpDialog.ui - qt_ui/vvDocumentation.ui - qt_ui/vvDicomSeriesSelector.ui - qt_ui/vvDummyWindow.ui #For testing - ) +if(vv_QT_VERSION VERSION_GREATER "4") + qt5_wrap_ui(vv_UI_CXX + qt_ui/vvHelpDialog.ui + qt_ui/vvDocumentation.ui + qt_ui/vvDicomSeriesSelector.ui + qt_ui/vvDummyWindow.ui #For testing + ) +else() + QT4_WRAP_UI(vv_UI_CXX + qt_ui/vvHelpDialog.ui + qt_ui/vvDocumentation.ui + qt_ui/vvDicomSeriesSelector.ui + qt_ui/vvDummyWindow.ui #For testing + ) +endif() -QT4_ADD_RESOURCES(vv_SRCS vvIcons.qrc) +if(vv_QT_VERSION VERSION_GREATER "4") + QT5_add_resources(vv_SRCS vvIcons.qrc) +else() + QT4_ADD_RESOURCES(vv_SRCS vvIcons.qrc) +endif() -# Add the autotools in the header vvToolsList.h for initialization of the dummy -# variables in vv.cxx for the tools contained in vvLib -if(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt IS_NEWER_THAN ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h) - file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h) - foreach(tool ${vv_TOOLS}) - file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h "#include \"${tool}.h\"\n") - file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h "extern const vvToolCreator<${tool}> *dummy${tool};\n") - file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h "const vvToolCreator<${tool}> *dummy${tool}2 = dummy${tool};\n\n") +# Add DICOM SERVER gui selector if the adequate GDCM is available +if(CLITK_USE_PACS_CONNECTION) + SET(vv_SRCS ${vv_SRCS} + vvQPacsConnection.cxx + vvPacsSettingsDialog.cxx + vvDicomServerQueryFactory.cxx + ) + if(vv_QT_VERSION VERSION_GREATER "4") + qt5_wrap_cpp(vv_SRCS vvQPacsConnection.h + vvPacsSettingsDialog.h) + qt5_wrap_ui(vv_UI_CXX + qt_ui/vvPacsConnection.ui + qt_ui/vvPacsSettingsDialog.ui) + else() + QT4_WRAP_CPP(vv_SRCS vvQPacsConnection.h + vvPacsSettingsDialog.h) + QT4_WRAP_UI(vv_UI_CXX + qt_ui/vvPacsConnection.ui + qt_ui/vvPacsSettingsDialog.ui) + endif() +endif(CLITK_USE_PACS_CONNECTION) + + # Add the autotools in the header vvToolsList.h for initialization of the dummy + # variables in vv.cxx for the tools contained in vvLib + if(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt IS_NEWER_THAN ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h) + file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h) + foreach(tool ${vv_TOOLS} ${vv_TOOLS_VTK7}) + file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h "#include \"${tool}.h\"\n") + file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h "extern const vvToolCreator<${tool}> *dummy${tool};\n") + file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h "const vvToolCreator<${tool}> *dummy${tool}2 = dummy${tool};\n\n") + endforeach(tool) + endif(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt IS_NEWER_THAN ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h) + + # Add the autotools and the common files ui + foreach(tool ${vv_TOOLS} ${vv_COMMON_WITH_UI}) + set(vv_SRCS ${vv_SRCS} ${tool}.cxx) + if(vv_QT_VERSION VERSION_GREATER "4") + QT5_WRAP_CPP(vv_SRCS ${tool}.h) + QT5_WRAP_UI(vv_UI_CXX qt_ui/${tool}.ui) + else() + QT4_WRAP_CPP(vv_SRCS ${tool}.h) + QT4_WRAP_UI(vv_UI_CXX qt_ui/${tool}.ui) + endif() endforeach(tool) -endif(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt IS_NEWER_THAN ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h) - -# Add the autotools and the common files ui -foreach(tool ${vv_TOOLS} ${vv_COMMON_WITH_UI}) - set(vv_SRCS ${vv_SRCS} ${tool}.cxx) - QT4_WRAP_CPP(vv_SRCS ${tool}.h) - QT4_WRAP_UI(vv_UI_CXX qt_ui/${tool}.ui) -endforeach(tool) - -# Add the common source files -foreach(tool ${vv_COMMON}) - set(vv_SRCS ${vv_SRCS} ${tool}.cxx) - QT4_WRAP_CPP(vv_SRCS ${tool}.h) -endforeach(tool) -# if Windows and Qt was built as a static lib then don't set QT_DLL flag -set(QT_STATIC 0) -if(WIN32) - if(EXISTS ${QT_LIBRARY_DIR}/QtCore.prl) - file(READ ${QT_LIBRARY_DIR}/QtCore.prl QT_CORE_PRL) - if(${QT_CORE_PRL} MATCHES "static") - set(QT_STATIC 1) - endif(${QT_CORE_PRL} MATCHES "static") - endif(EXISTS ${QT_LIBRARY_DIR}/QtCore.prl) -endif(WIN32) -if(NOT QT_STATIC) - add_definitions(-DQT_DLL) -endif(NOT QT_STATIC) - -add_definitions(-DQT_THREAD_SUPPORT) + #Special case for Main Window with QVTKWidget according VTK version + foreach(tool ${vv_TOOLS_VTK7} ${vv_COMMON_WITH_UI_VTK7}) + set(vv_SRCS ${vv_SRCS} ${tool}.cxx) + if(VTK_VERSION VERSION_LESS "8.2.0") + if(vv_QT_VERSION VERSION_GREATER "4") + QT5_WRAP_CPP(vv_SRCS ${tool}.h) + QT5_WRAP_UI(vv_UI_CXX qt_ui/${tool}VTK7.ui) + else() + QT4_WRAP_CPP(vv_SRCS ${tool}.h) + QT4_WRAP_UI(vv_UI_CXX qt_ui/${tool}VTK7.ui) + endif() + else() + if(vv_QT_VERSION VERSION_GREATER "4") + QT5_WRAP_CPP(vv_SRCS ${tool}.h) + QT5_WRAP_UI(vv_UI_CXX qt_ui/${tool}.ui) + else() + QT4_WRAP_CPP(vv_SRCS ${tool}.h) + QT4_WRAP_UI(vv_UI_CXX qt_ui/${tool}.ui) + endif() + endif() + endforeach(tool) + + # Add the common source files + foreach(tool ${vv_COMMON}) + set(vv_SRCS ${vv_SRCS} ${tool}.cxx) + if(vv_QT_VERSION VERSION_GREATER "4") + QT5_WRAP_CPP(vv_SRCS ${tool}.h) + else() + QT4_WRAP_CPP(vv_SRCS ${tool}.h) + endif() + endforeach(tool) + + # if Windows and Qt was built as a static lib then don't set QT_DLL flag + set(QT_STATIC 0) + if(WIN32) + if(vv_QT_VERSION VERSION_GREATER "4") + if(EXISTS ${Qt5Widgets_LIBRARIES}/QtCore.prl) + file(READ ${Qt5Widgets_LIBRARIES}/QtCore.prl QT_CORE_PRL) + if(${QT_CORE_PRL} MATCHES "static") + set(QT_STATIC 1) + endif(${QT_CORE_PRL} MATCHES "static") + endif(EXISTS ${Qt5Widgets_LIBRARIES}/QtCore.prl) + else() + if(EXISTS ${QT_LIBRARY_DIR}/QtCore.prl) + file(READ ${QT_LIBRARY_DIR}/QtCore.prl QT_CORE_PRL) + if(${QT_CORE_PRL} MATCHES "static") + set(QT_STATIC 1) + endif(${QT_CORE_PRL} MATCHES "static") + endif(EXISTS ${QT_LIBRARY_DIR}/QtCore.prl) + endif() + endif(WIN32) + if(NOT QT_STATIC) + add_definitions(-DQT_DLL) + endif(NOT QT_STATIC) -include_directories( - ${QT_INCLUDES} - ${QT_INCLUDE_DIR} - ${QT_QTGUI_INCLUDE_DIR} - ${QT_QTCORE_INCLUDE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} -) + add_definitions(-DQT_THREAD_SUPPORT) + if(vv_QT_VERSION VERSION_GREATER "4") + include_directories( + ${Qt5Widgets_INCLUDE_DIRS} + ${Qt5Gui_INCLUDE_DIRS} + ${Qt5Core_INCLUDE_DIRS} + ${Qt5Network_INCLUDE_DIRS} + ${Qt5Designer_INCLUDE_DIRS} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ) + else() + include_directories( + ${QT_INCLUDES} + ${QT_INCLUDE_DIR} + ${QT_QTGUI_INCLUDE_DIR} + ${QT_QTCORE_INCLUDE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ) + endif() #========================================================= #========================================================= @@ -199,23 +332,25 @@ include_directories( #========================================================= #Add each tool's dependencies -foreach(tool ${vv_TOOLS}) +foreach(tool ${vv_TOOLS} ${vv_TOOLS_VTK7}) set(toolLibs ${toolLibs} ${${tool}_LIBS}) endforeach(tool) #========================================================= #Add Foundation Libraries (this should be after our libraries, since we depend #on them) +if(VTK_VERSION VERSION_GREATER "6.2.0") +set(foundationLibraries clitkCommon ${ITK_LIBRARIES} ${VTK_LIBRARIES}) +else() set(foundationLibraries clitkCommon ${ITK_LIBRARIES} QVTK vtkHybrid) +endif() #========================================================= # Use CxImage to create animated gifs -if(CLITK_EXPERIMENTAL) - set(vvCxImage clitkCxImage) - set(vv_SRCS ${vv_SRCS} vvAnimatedGIFWriter.cxx) - include_directories(${CLITK_SOURCE_DIR}/utilities/CxImage) - add_subdirectory(${CLITK_SOURCE_DIR}/utilities/CxImage ${PROJECT_BINARY_DIR}/utilities/CxImage) -endif(CLITK_EXPERIMENTAL) +set(vvCxImage clitkCxImage) +set(vv_SRCS ${vv_SRCS} vvAnimatedGIFWriter.cxx) +include_directories(${CLITK_SOURCE_DIR}/utilities/CxImage) +add_subdirectory(${CLITK_SOURCE_DIR}/utilities/CxImage ${PROJECT_BINARY_DIR}/utilities/CxImage) #========================================================= #----------------------------------------------------------------------------- @@ -236,8 +371,19 @@ if(APPLE) endif() #========================================================= #Create binary and libs for tests -set(vvExternalLibs clitkSegmentationGgoLib ${toolLibs} ${foundationLibraries} ${vvCxImage} ${QT_LIBRARIES} ${QT_QTNETWORK_LIBRARY} ${APPLE_FRAMEWORKS}) -# QtNetwork is required by vvRegisterForm +if(vv_QT_VERSION VERSION_GREATER "4") +set(vvExternalLibs clitkSegmentationGgoLib ${toolLibs} ${foundationLibraries} ${vvCxImage} Qt5::Widgets Qt5::Network Qt5::Designer ${APPLE_FRAMEWORKS}) +else() +set(vvExternalLibs clitkSegmentationGgoLib ${toolLibs} ${foundationLibraries} ${vvCxImage} ${QT_LIBRARIES} ${APPLE_FRAMEWORKS}) +endif() +# QtNetwork is required by vvRegisterForm ${QT_QTNETWORK_LIBRARY} + +#----------------------------------------------------------------------------- +# For retina displays, see +# http://public.kitware.com/pipermail/vtkusers/2015-February/090117.html +if(APPLE) + set(vv_SRCS ${vv_SRCS} vvOSXHelper.mm) +endif() add_library(vvLib ${vv_SRCS} ${vv_UI_CXX}) target_link_libraries(vvLib ${vvExternalLibs}) @@ -252,7 +398,7 @@ target_link_libraries(vv vvLib) #========================================================= # Install options (also used by CPack) -install(TARGETS vv DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE) +install(TARGETS vv DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) #=========================================================