From a99c26946ea3a858847b76368bbf312019de9c2a Mon Sep 17 00:00:00 2001 From: Leonardo Florez-Valencia Date: Mon, 27 Jun 2016 17:40:33 -0500 Subject: [PATCH] ... --- CMakeLists.txt | 21 ++--- appli/plugins/CMakeLists.txt | 1 + cmake/cpPluginsConfig.cmake.in | 137 ++++++++++++++++++++++----------- 3 files changed, 104 insertions(+), 55 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 28e32f4..25e62fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,16 +31,19 @@ INCLUDE(cmake/cpPlugins_Qt4Tools.cmake) ## == Include directories == ## ========================= -INCLUDE_DIRECTORIES( - ${PROJECT_SOURCE_DIR} - ${PROJECT_BINARY_DIR} - ${PROJECT_SOURCE_DIR}/lib - ${PROJECT_BINARY_DIR}/lib - ${PROJECT_SOURCE_DIR}/lib/Itk2Vtk - ${PROJECT_BINARY_DIR}/lib/Itk2Vtk - ${PROJECT_SOURCE_DIR}/lib/Instances - ${PROJECT_BINARY_DIR}/lib/Instances +SET( + cpPlugins_RELATIVE_INCLUDE_DIRS + . + lib + lib/Itk2Vtk + lib/Instances ) +SET(cpPlugins_INCLUDE_DIRS) +FOREACH(_d ${cpPlugins_RELATIVE_INCLUDE_DIRS}) + LIST(APPEND cpPlugins_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/${_d}) + LIST(APPEND cpPlugins_INCLUDE_DIRS ${PROJECT_BINARY_DIR}/${_d}) +ENDFOREACH(_d) +INCLUDE_DIRECTORIES(${cpPlugins_INCLUDE_DIRS}) ## ============================= ## == Subdirs containing code == diff --git a/appli/plugins/CMakeLists.txt b/appli/plugins/CMakeLists.txt index 5c99f74..59a5076 100644 --- a/appli/plugins/CMakeLists.txt +++ b/appli/plugins/CMakeLists.txt @@ -16,6 +16,7 @@ FOREACH(source ${all_SOURCE_CXX_FILES}) GET_FILENAME_COMPONENT(name ${source} NAME_WE) ADD_EXECUTABLE(${name} ${source}) TARGET_LINK_LIBRARIES(${name} ${cpPlugins_LIB}) + SET(${name}_APP ${name} CACHE INTERNAL "plugin program ${name}") ENDFOREACH(source) ## eof - $RCSfile$ diff --git a/cmake/cpPluginsConfig.cmake.in b/cmake/cpPluginsConfig.cmake.in index 42871e9..6def2e7 100644 --- a/cmake/cpPluginsConfig.cmake.in +++ b/cmake/cpPluginsConfig.cmake.in @@ -3,46 +3,67 @@ ## ================================= FIND_FILE( - cpPlugins_FUNCTIONS + cpPlugins_Functions_cmake NAMES cpPlugins_Functions.cmake HINTS /usr/share/cmake /usr/local/share/cmake PATHS @CMAKE_INSTALL_PREFIX@/share/cmake @PROJECT_SOURCE_DIR@/cmake DOC "Where is \"cpPlugins_Functions.cmake\"?" ) -IF(NOT cpPlugins_FUNCTIONS) +IF(NOT cpPlugins_Functions_cmake) MESSAGE(FATAL_ERROR "Where is \"cpPlugins_Functions.cmake\"?") -ENDIF(NOT cpPlugins_FUNCTIONS) -GET_FILENAME_COMPONENT( - cpPlugins_FUNCTIONS_ABSOLUTE ${cpPlugins_FUNCTIONS} - ABSOLUTE - ) -GET_FILENAME_COMPONENT( - cpPlugins_CMAKE_DIR ${cpPlugins_FUNCTIONS_ABSOLUTE} - DIRECTORY - ) +ENDIF(NOT cpPlugins_Functions_cmake) +INCLUDE(${cpPlugins_Functions_cmake}) -## =========================== -## == Include cmake scripts == -## =========================== +FIND_FILE( + cpPlugins_Options_cmake + NAMES cpPlugins_Options.cmake + HINTS /usr/share/cmake /usr/local/share/cmake + PATHS @CMAKE_INSTALL_PREFIX@/share/cmake @PROJECT_SOURCE_DIR@/cmake + DOC "Where is \"cpPlugins_Options.cmake\"?" + ) +IF(NOT cpPlugins_Options_cmake) + MESSAGE(FATAL_ERROR "Where is \"cpPlugins_Options.cmake\"?") +ENDIF(NOT cpPlugins_Options_cmake) +INCLUDE(${cpPlugins_Options_cmake}) -INCLUDE(${cpPlugins_FUNCTIONS}) -INCLUDE(${cpPlugins_CMAKE_DIR}/cpPlugins_Options.cmake) +## ========================= +## == Find base libraries == +## ========================= SET(ITK_DIR @ITK_DIR@) SET(VTK_DIR @VTK_DIR@) -INCLUDE(${cpPlugins_CMAKE_DIR}/cpPlugins_KitwareTools.cmake) +FIND_PACKAGE(ITK REQUIRED) +FIND_PACKAGE(VTK REQUIRED) +INCLUDE(${ITK_USE_FILE}) +INCLUDE(${VTK_USE_FILE}) +IF(ITKVtkGlue_LOADED) + MESSAGE(FATAL_ERROR "ITKVtkGlue module is available. Please re-compile your ITK without it. It could lead to nasty compilation problems... Just waiting for Kitware to solve it.") +ENDIF(ITKVtkGlue_LOADED) SET(USE_QT4 "@QT4_FOUND@") IF(USE_QT4 EQUAL "1") - INCLUDE(${cpPlugins_CMAKE_DIR}/cpPlugins_Qt4Tools.cmake) - cpPlugins_FindQt4() SET(QT_QMAKE_EXECUTABLE @QT_QMAKE_EXECUTABLE@) + FIND_PACKAGE(Qt4 REQUIRED) + INCLUDE(${QT_USE_FILE}) + SET( + _required_vtk_modules + vtkGUISupportQt + vtkGUISupportQtOpenGL + ) + FOREACH(_m ${_required_vtk_modules}) + IF(NOT ${_m}_LOADED) + MESSAGE(FATAL_ERROR "${_m} module is required but not available.") + BREAK() + ENDIF(NOT ${_m}_LOADED) + ENDFOREACH(_m) + SET(QT4_FOUND "1") ENDIF(USE_QT4 EQUAL "1") ## ========================= ## == Include directories == ## ========================= +## TODO: this is not completely correct!!! INCLUDE_DIRECTORIES( @CMAKE_INSTALL_PREFIX@/include @CMAKE_INSTALL_PREFIX@/include/cpPlugins/Itk2Vtk @@ -57,49 +78,73 @@ INCLUDE_DIRECTORIES( @PROJECT_BINARY_DIR@/lib/Instances ) -## ========================= -## == Library directories == -## ========================= - -IF(MSVC) - LINK_DIRECTORIES( - @PROJECT_BINARY_DIR@/$(ConfigurationName) - @CMAKE_INSTALL_PREFIX@/bin - @CMAKE_INSTALL_PREFIX@/lib - ) -ELSE(MSVC) - LINK_DIRECTORIES( - @PROJECT_BINARY_DIR@ - @CMAKE_INSTALL_PREFIX@/bin - @CMAKE_INSTALL_PREFIX@/lib - ) -ENDIF(MSVC) - -## =================== -## == Library names == -## =================== +## =================================== +## == Library names and directories == +## =================================== SET(cpPlugins_tinyxml2_LIB "@cpPlugins_tinyxml2_LIB@") SET(cpExtensions_LIB "@cpExtensions_LIB@") SET(cpPlugins_LIB "@cpPlugins_LIB@") SET(cpBaseQtApplication_LIB "@cpBaseQtApplication_LIB@") SET(cpPlugins_Instances "@cpPlugins_Instances@") +SET( + _all_libs + ${cpPlugins_tinyxml2_LIB} + ${cpExtensions_LIB} + ${cpPlugins_LIB} + ${cpBaseQtApplication_LIB} + ${cpPlugins_Instances} + ) + +SET(_l_locations) +FOREACH(_l ${_all_libs}) + SET(cpPlugins_library_location) + IF(MSVC) + FIND_LIBRARY( + cpPlugins_library_location_${_l} NAMES ${_l} + HINTS + @PROJECT_BINARY_DIR@/$(ConfigurationName) + @CMAKE_INSTALL_PREFIX@/bin + @CMAKE_INSTALL_PREFIX@/lib + ) + ELSE(MSVC) + FIND_LIBRARY( + cpPlugins_library_location_${_l} NAMES ${_l} + HINTS + @PROJECT_BINARY_DIR@ + @CMAKE_INSTALL_PREFIX@/bin + @CMAKE_INSTALL_PREFIX@/lib + ) + ENDIF(MSVC) + MARK_AS_ADVANCED(FORCE cpPlugins_library_location_${_l}) + IF(cpPlugins_library_location_${_l}) + GET_FILENAME_COMPONENT(_dir ${cpPlugins_library_location_${_l}} DIRECTORY) + LIST(APPEND _l_locations ${_dir}) + ENDIF(cpPlugins_library_location_${_l}) +ENDFOREACH(_l) +IF(_l_locations) + LIST(REMOVE_DUPLICATES _l_locations) + LINK_DIRECTORIES(${_l_locations}) +ENDIF(_l_locations) ## ====================== ## == Executable names == ## ====================== + SET( - exec_PROGRAMS - cpPlugins_CreateInstances - cpPlugins_HostCreator + _exec_programs + @cpPlugins_CreateInstances_APP@ + @cpPlugins_HostCreator_APP@ + @cpPlugins_ExecuteWorkspace_APP@ ) -FOREACH(prog ${exec_PROGRAMS}) + +FOREACH(prog ${_exec_programs}) IF(MSVC) FIND_PROGRAM( ${prog}_APP NAMES ${prog} HINTS /usr /usr/local - PATHS @CMAKE_INSTALL_PREFIX@/bin @PROJECT_BINARY_DIR@/Debug @PROJECT_BINARY_DIR@/Release @PROJECT_BINARY_DIR@/MinSizeRel @PROJECT_BINARY_DIR@/RelWithDebInfo + PATHS @CMAKE_INSTALL_PREFIX@/bin @PROJECT_BINARY_DIR@/$(ConfigurationName) PATH_SUFFIXES bin sbin DOC "Where is ${prog}?" ) @@ -115,4 +160,4 @@ FOREACH(prog ${exec_PROGRAMS}) ENDIF(MSVC) ENDFOREACH(prog) -## eof - $RCSfile$ +# ## eof - $RCSfile$ -- 2.47.1