From cdf6f8196859370fe299511dcd58d97522bcd8f3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leonardo=20Fl=C3=B3rez-Valencia?= Date: Tue, 3 Oct 2017 16:04:11 -0500 Subject: [PATCH] ... --- CMakeLists.txt | 68 ++++++++++--------- cmake/CMakeLists.txt | 12 ++++ ...finitions.cmake => cpPlgDefinitions.cmake} | 0 .../{Functions.cmake => cpPlgFunctions.cmake} | 0 ...mands.cmake => cpPlgInstallCommands.cmake} | 14 ++-- cmake/cpPluginsConfig.cmake.in | 40 +++++++---- 6 files changed, 83 insertions(+), 51 deletions(-) create mode 100644 cmake/CMakeLists.txt rename cmake/{Definitions.cmake => cpPlgDefinitions.cmake} (100%) rename cmake/{Functions.cmake => cpPlgFunctions.cmake} (100%) rename cmake/{InstallCommands.cmake => cpPlgInstallCommands.cmake} (83%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 819a52f..9c11937 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,36 +22,42 @@ foreach(_p ${_policies}) endforeach(_p) ## == Some general configuration -include(cmake/Definitions.cmake) -include(cmake/Functions.cmake) - -## == Find ITK -find_package(ITK CONFIG REQUIRED) -include(${ITK_USE_FILE}) - -## == Find VTK, only if linked against ITK -set(cpPlugins_USE_VTK 0) -if(ITKVtkGlue_LOADED) - find_package(VTK CONFIG REQUIRED) - include(${VTK_USE_FILE}) - set(cpPlugins_USE_VTK 1) -endif(ITKVtkGlue_LOADED) - -## == Find Qt5, only if linked against VTK -set(cpPlugins_USE_Qt5 0) -if(VTK_FOUND) - if(Qt5_DIR) - find_package(Qt5 CONFIG REQUIRED COMPONENTS Widgets) - set(CMAKE_INCLUDE_CURRENT_DIR ON) - set(CMAKE_AUTOMOC ON) - set(cpPlugins_USE_Qt5 1) - endif(Qt5_DIR) -endif(VTK_FOUND) - -## == Build packages -subdirs(appli lib) - -## == Installation commands -include(cmake/InstallCommands.cmake) +include(cmake/cpPlgDefinitions.cmake) +include(cmake/cpPlgFunctions.cmake) + +## == User could choose not to build +option(cpPlugins_BUILD "Build targets." OFF) +if(cpPlugins_BUILD) + + ## == Find ITK + find_package(ITK CONFIG REQUIRED) + include(${ITK_USE_FILE}) + + ## == Find VTK, only if linked against ITK + set(cpPlugins_USE_VTK 0) + if(ITKVtkGlue_LOADED) + find_package(VTK CONFIG REQUIRED) + include(${VTK_USE_FILE}) + set(cpPlugins_USE_VTK 1) + endif(ITKVtkGlue_LOADED) + + ## == Find Qt5, only if linked against VTK + set(cpPlugins_USE_Qt5 0) + if(VTK_FOUND) + if(Qt5_DIR) + find_package(Qt5 CONFIG REQUIRED COMPONENTS Widgets) + set(CMAKE_INCLUDE_CURRENT_DIR ON) + set(CMAKE_AUTOMOC ON) + set(cpPlugins_USE_Qt5 1) + endif(Qt5_DIR) + endif(VTK_FOUND) + + ## == Build packages + subdirs(appli lib) + +endif(cpPlugins_BUILD) + +## == CMake scripts +subdirs(cmake) ## eof - $RCSfile$ diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt new file mode 100644 index 0000000..bb36430 --- /dev/null +++ b/cmake/CMakeLists.txt @@ -0,0 +1,12 @@ +## ========================================================================= +## @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co) +## ========================================================================= + +include(cpPlgInstallCommands.cmake) + +#INSTALL: cpPlgDefinitions.cmake +#INSTALL: cpPlgFunctions.cmake +#INSTALL: cpPlgInstallCommands.cmake + +## eof - $RCSfile$ + diff --git a/cmake/Definitions.cmake b/cmake/cpPlgDefinitions.cmake similarity index 100% rename from cmake/Definitions.cmake rename to cmake/cpPlgDefinitions.cmake diff --git a/cmake/Functions.cmake b/cmake/cpPlgFunctions.cmake similarity index 100% rename from cmake/Functions.cmake rename to cmake/cpPlgFunctions.cmake diff --git a/cmake/InstallCommands.cmake b/cmake/cpPlgInstallCommands.cmake similarity index 83% rename from cmake/InstallCommands.cmake rename to cmake/cpPlgInstallCommands.cmake index 97500ae..cbfc91c 100644 --- a/cmake/InstallCommands.cmake +++ b/cmake/cpPlgInstallCommands.cmake @@ -23,15 +23,17 @@ write_basic_package_version_file( "${version_config}" COMPATIBILITY SameMajorVersion ) configure_package_config_file( - "cmake/${PROJECT_NAME}Config.cmake.in" + "${PROJECT_NAME}Config.cmake.in" "${project_config}" INSTALL_DESTINATION "${config_install_dir}" ) -install( - EXPORT "${targets_export_name}" - NAMESPACE "${namespace}" - DESTINATION "${config_install_dir}" - ) +if(${PROJECT_NAME}_BUILD) + install( + EXPORT "${targets_export_name}" + NAMESPACE "${namespace}" + DESTINATION "${config_install_dir}" + ) +endif(${PROJECT_NAME}_BUILD) install( FILES "${project_config}" DESTINATION "${config_install_dir}" diff --git a/cmake/cpPluginsConfig.cmake.in b/cmake/cpPluginsConfig.cmake.in index 891261c..58d75fa 100644 --- a/cmake/cpPluginsConfig.cmake.in +++ b/cmake/cpPluginsConfig.cmake.in @@ -1,26 +1,38 @@ +## == Some general configuration +include(@CMAKE_INSTALL_PREFIX@/lib/cmake/@PROJECT_NAME@/cpPlgDefinitions.cmake) +include(@CMAKE_INSTALL_PREFIX@/lib/cmake/@PROJECT_NAME@/cpPlgFunctions.cmake) + +## == Automatically generated commands @PACKAGE_INIT@ include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake") check_required_components("@PROJECT_NAME@") -## =========================================== -## == Find needed packages and dependencies == -## =========================================== - -set(ITK_DIR "@ITK_DIR@") -set(VTK_DIR "@VTK_DIR@") -set(Qt5_DIR "@Qt5_DIR@") +## ====================================== +## == Needed packages and dependencies == +## ====================================== +## == Find ITK find_package(ITK CONFIG REQUIRED) include(${ITK_USE_FILE}) -if(NOT "${VTK_DIR}" STREQUAL "") + +## == Find VTK, only if linked against ITK +set(cpPlugins_USE_VTK 0) +if(ITKVtkGlue_LOADED) find_package(VTK CONFIG REQUIRED) include(${VTK_USE_FILE}) -endif(NOT "${VTK_DIR}" STREQUAL "") -if(NOT "${Qt5_DIR}" STREQUAL "") - find_package(Qt5 CONFIG REQUIRED COMPONENTS Widgets) - set(CMAKE_INCLUDE_CURRENT_DIR ON) - set(CMAKE_AUTOMOC ON) -endif(NOT "${Qt5_DIR}" STREQUAL "") + set(cpPlugins_USE_VTK 1) +endif(ITKVtkGlue_LOADED) + +## == Find Qt5, only if linked against VTK +set(cpPlugins_USE_Qt5 0) +if(VTK_FOUND) + if(Qt5_DIR) + find_package(Qt5 CONFIG REQUIRED COMPONENTS Widgets) + set(CMAKE_INCLUDE_CURRENT_DIR ON) + set(CMAKE_AUTOMOC ON) + set(cpPlugins_USE_Qt5 1) + endif(Qt5_DIR) +endif(VTK_FOUND) ## eof - $RCSfile$ -- 2.47.1