diff --git a/CMake/elastixExportTarget.cmake b/CMake/elastixExportTarget.cmake index d00038d26..b0e36a641 100644 --- a/CMake/elastixExportTarget.cmake +++ b/CMake/elastixExportTarget.cmake @@ -23,16 +23,51 @@ function(elastix_export_target tgt) set_property(TARGET ${tgt} PROPERTY OUTPUT_NAME ${tgt}-${ELASTIX_VERSION_MAJOR}.${ELASTIX_VERSION_MINOR}) endif() + + if(type STREQUAL "STATIC_LIBRARY") + if(NOT ELASTIX_NO_INSTALL_DEVELOPMENT) + install(TARGETS ${tgt} + EXPORT ElastixTargets + RUNTIME DESTINATION ${ELASTIX_INSTALL_RUNTIME_DIR} + LIBRARY DESTINATION ${ELASTIX_INSTALL_LIBRARY_DIR} + ARCHIVE DESTINATION ${ELASTIX_INSTALL_ARCHIVE_DIR} + COMPONENT Development + ) + endif() + else() + if(NOT ELASTIX_NO_INSTALL_RUNTIME_LIBRARIES) + install(TARGETS ${tgt} + EXPORT ElastixTargets + RUNTIME DESTINATION ${ELASTIX_INSTALL_RUNTIME_DIR} + LIBRARY DESTINATION ${ELASTIX_INSTALL_LIBRARY_DIR} + ARCHIVE DESTINATION ${ELASTIX_INSTALL_ARCHIVE_DIR} + COMPONENT RuntimeLibraries + ) + endif() + endif() + elseif(type STREQUAL "EXECUTABLE") + if(NOT ELASTIX_NO_INSTALL_RUNTIME_LIBRARIES) + install(TARGETS ${tgt} + EXPORT ElastixTargets + RUNTIME DESTINATION ${ELASTIX_INSTALL_RUNTIME_DIR} + LIBRARY DESTINATION ${ELASTIX_INSTALL_LIBRARY_DIR} + ARCHIVE DESTINATION ${ELASTIX_INSTALL_ARCHIVE_DIR} + COMPONENT Executables + ) + endif() + else() + if(NOT ELASTIX_NO_INSTALL_DEVELOPMENT) + install(TARGETS ${tgt} + EXPORT ElastixTargets + RUNTIME DESTINATION ${ELASTIX_INSTALL_RUNTIME_DIR} + LIBRARY DESTINATION ${ELASTIX_INSTALL_LIBRARY_DIR} + ARCHIVE DESTINATION ${ELASTIX_INSTALL_ARCHIVE_DIR} + COMPONENT Development + ) + endif() endif() export(TARGETS ${tgt} APPEND FILE "${elastix_BINARY_DIR}/ElastixTargets.cmake" ) - - install(TARGETS ${tgt} - EXPORT ElastixTargets - RUNTIME DESTINATION ${ELASTIX_INSTALL_RUNTIME_DIR} - LIBRARY DESTINATION ${ELASTIX_INSTALL_LIBRARY_DIR} - ARCHIVE DESTINATION ${ELASTIX_INSTALL_ARCHIVE_DIR} - ) endfunction() diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f84b9dd4..d9cd5dd49 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -203,6 +203,13 @@ if(NOT ELASTIX_INSTALL_PACKAGE_DIR) set(ELASTIX_INSTALL_PACKAGE_DIR "${ELASTIX_LIBRARY_DIR}/cmake/elastix") endif() +#--------------------------------------------------------------------- +# Provide options to avoid installing runtime or development components +option(ELASTIX_NO_INSTALL_RUNTIME_LIBRARIES "Do not install runtime libraries" OFF) +option(ELASTIX_NO_INSTALL_EXECUTABLES "Do not install executables" OFF) +option(ELASTIX_NO_INSTALL_DEVELOPMENT "Do not install development headers and static libraries" OFF) +mark_as_advanced(ELASTIX_NO_INSTALL_EXECUTABLES ELASTIX_NO_INSTALL_RUNTIME_LIBRARIES ELASTIX_NO_INSTALL_DEVELOPMENT) + #--------------------------------------------------------------------- # Check if Mevis DicomTiff support is desired mark_as_advanced(ELASTIX_USE_MEVISDICOMTIFF) @@ -637,15 +644,17 @@ configure_file(ElastixConfig.cmake.in "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECT configure_file(ElastixConfigVersion.cmake.in ElastixConfigVersion.cmake @ONLY) configure_file(UseElastix.cmake.in UseElastix.cmake @ONLY) -install(FILES - "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/ElastixConfig.cmake" - "${PROJECT_BINARY_DIR}/ElastixConfigVersion.cmake" - "${PROJECT_BINARY_DIR}/UseElastix.cmake" - DESTINATION ${ELASTIX_INSTALL_PACKAGE_DIR} - COMPONENT Development - ) - -install(EXPORT ElastixTargets - DESTINATION ${ELASTIX_INSTALL_PACKAGE_DIR} - COMPONENT Development - ) +if(NOT ELASTIX_NO_INSTALL_DEVELOPMENT) + install(FILES + "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/ElastixConfig.cmake" + "${PROJECT_BINARY_DIR}/ElastixConfigVersion.cmake" + "${PROJECT_BINARY_DIR}/UseElastix.cmake" + DESTINATION ${ELASTIX_INSTALL_PACKAGE_DIR} + COMPONENT Development + ) + + install(EXPORT ElastixTargets + DESTINATION ${ELASTIX_INSTALL_PACKAGE_DIR} + COMPONENT Development + ) +endif() diff --git a/Common/CMakeLists.txt b/Common/CMakeLists.txt index bb775d413..07c516644 100644 --- a/Common/CMakeLists.txt +++ b/Common/CMakeLists.txt @@ -202,10 +202,14 @@ add_library(elxCommon STATIC ${LineSearchOptimizersFiles} ${ImageSamplersFiles} ) -install(TARGETS elxCommon - ARCHIVE DESTINATION ${ELASTIX_ARCHIVE_DIR} - LIBRARY DESTINATION ${ELASTIX_LIBRARY_DIR} - RUNTIME DESTINATION ${ELASTIX_RUNTIME_DIR}) +if(NOT ELASTIX_NO_INSTALL_DEVELOPMENT) + install(TARGETS elxCommon + ARCHIVE DESTINATION ${ELASTIX_ARCHIVE_DIR} + LIBRARY DESTINATION ${ELASTIX_LIBRARY_DIR} + RUNTIME DESTINATION ${ELASTIX_RUNTIME_DIR} + COMPONENT Development + ) +endif() #--------------------------------------------------------------------- # Link against other libraries. diff --git a/Common/MevisDicomTiff/CMakeLists.txt b/Common/MevisDicomTiff/CMakeLists.txt index 307e17436..3a72dc133 100644 --- a/Common/MevisDicomTiff/CMakeLists.txt +++ b/Common/MevisDicomTiff/CMakeLists.txt @@ -16,10 +16,13 @@ else() ) endif() -install(TARGETS mevisdcmtiff - ARCHIVE DESTINATION ${ELASTIX_ARCHIVE_DIR} - LIBRARY DESTINATION ${ELASTIX_LIBRARY_DIR} - RUNTIME DESTINATION ${ELASTIX_RUNTIME_DIR}) +if(NOT ELASTIX_NO_INSTALL_DEVELOPMENT) + install(TARGETS mevisdcmtiff + ARCHIVE DESTINATION ${ELASTIX_ARCHIVE_DIR} + LIBRARY DESTINATION ${ELASTIX_LIBRARY_DIR} + RUNTIME DESTINATION ${ELASTIX_RUNTIME_DIR} + COMPONENT Development) +endif() target_link_libraries(mevisdcmtiff ${ITK_LIBRARIES}) diff --git a/Common/OpenCL/CMakeLists.txt b/Common/OpenCL/CMakeLists.txt index d7ae6040a..a090e90ef 100644 --- a/Common/OpenCL/CMakeLists.txt +++ b/Common/OpenCL/CMakeLists.txt @@ -64,9 +64,12 @@ target_link_libraries(elxOpenCL # Group in IDE's like Visual Studio set_property(TARGET elxOpenCL PROPERTY FOLDER "libraries") -install(TARGETS elxOpenCL - ARCHIVE DESTINATION ${ELASTIX_ARCHIVE_DIR} - LIBRARY DESTINATION ${ELASTIX_LIBRARY_DIR} - RUNTIME DESTINATION ${ELASTIX_RUNTIME_DIR}) +if(NOT ELASTIX_NO_INSTALL_DEVELOPMENT) + install(TARGETS elxOpenCL + ARCHIVE DESTINATION ${ELASTIX_ARCHIVE_DIR} + LIBRARY DESTINATION ${ELASTIX_LIBRARY_DIR} + RUNTIME DESTINATION ${ELASTIX_RUNTIME_DIR} + COMPONENT Development) +endif() elastix_export_target(elxOpenCL) diff --git a/Common/ParameterFileParser/CMakeLists.txt b/Common/ParameterFileParser/CMakeLists.txt index 1a5784a25..953f587b3 100644 --- a/Common/ParameterFileParser/CMakeLists.txt +++ b/Common/ParameterFileParser/CMakeLists.txt @@ -9,10 +9,13 @@ set(param_SRCS source_group("Parser" FILES ${param_SRCS}) add_library(param STATIC ${param_SRCS}) -install(TARGETS param - ARCHIVE DESTINATION ${ELASTIX_ARCHIVE_DIR} - LIBRARY DESTINATION ${ELASTIX_LIBRARY_DIR} - RUNTIME DESTINATION ${ELASTIX_RUNTIME_DIR}) +if(NOT ELASTIX_NO_INSTALL_DEVELOPMENT) + install(TARGETS param + ARCHIVE DESTINATION ${ELASTIX_ARCHIVE_DIR} + LIBRARY DESTINATION ${ELASTIX_LIBRARY_DIR} + RUNTIME DESTINATION ${ELASTIX_RUNTIME_DIR} + COMPONENT Development) +endif() target_link_libraries(param ${ITK_LIBRARIES}) diff --git a/Common/xout/CMakeLists.txt b/Common/xout/CMakeLists.txt index 7224a3845..fcaf9d7da 100644 --- a/Common/xout/CMakeLists.txt +++ b/Common/xout/CMakeLists.txt @@ -20,10 +20,13 @@ set(xouthfiles # a lib defining the global variable xout. add_library(xoutlib STATIC ${xoutcxxfiles} ${xouthfiles}) -install(TARGETS xoutlib - ARCHIVE DESTINATION ${ELASTIX_ARCHIVE_DIR} - LIBRARY DESTINATION ${ELASTIX_LIBRARY_DIR} - RUNTIME DESTINATION ${ELASTIX_RUNTIME_DIR}) +if(NOT ELASTIX_NO_INSTALL_DEVELOPMENT) + install(TARGETS xoutlib + ARCHIVE DESTINATION ${ELASTIX_ARCHIVE_DIR} + LIBRARY DESTINATION ${ELASTIX_LIBRARY_DIR} + RUNTIME DESTINATION ${ELASTIX_RUNTIME_DIR} + COMPONENT Development) +endif() # Group in IDE's like Visual Studio set_property(TARGET xoutlib PROPERTY FOLDER "libraries") diff --git a/Components/CMakeLists.txt b/Components/CMakeLists.txt index 09b6ece5d..8a7bff6bb 100644 --- a/Components/CMakeLists.txt +++ b/Components/CMakeLists.txt @@ -129,10 +129,13 @@ macro(ADD_ELXCOMPONENT name) project(${name}) add_library(${name} STATIC ${filelist}) target_link_libraries(${name} ${elxLinkLibs}) - install(TARGETS ${name} - ARCHIVE DESTINATION ${ELASTIX_ARCHIVE_DIR} - LIBRARY DESTINATION ${ELASTIX_LIBRARY_DIR} - RUNTIME DESTINATION ${ELASTIX_RUNTIME_DIR}) + if(NOT ELASTIX_NO_INSTALL_DEVELOPMENT) + install(TARGETS ${name} + ARCHIVE DESTINATION ${ELASTIX_ARCHIVE_DIR} + LIBRARY DESTINATION ${ELASTIX_LIBRARY_DIR} + RUNTIME DESTINATION ${ELASTIX_RUNTIME_DIR} + COMPONENT Development) + endif() # Group in IDE's like Visual Studio string(REGEX MATCH "[a-zA-Z]+" comp_group ${relative_path_to_comp}) diff --git a/Components/Metrics/KNNGraphAlphaMutualInformation/CMakeLists.txt b/Components/Metrics/KNNGraphAlphaMutualInformation/CMakeLists.txt index 2e00e0e42..39490c0f5 100644 --- a/Components/Metrics/KNNGraphAlphaMutualInformation/CMakeLists.txt +++ b/Components/Metrics/KNNGraphAlphaMutualInformation/CMakeLists.txt @@ -8,6 +8,9 @@ ADD_ELXCOMPONENT( KNNGraphAlphaMutualInformationMetric ) if(USE_KNNGraphAlphaMutualInformationMetric) + if(ELASTIX_NO_INSTALL_RUNTIME_LIBRARIES AND NOT ELASTIX_NO_INSTALL_DEVELOPMENT) + message(SEND_ERROR "USE_KNNGraphAlphaMutualInformationMetric with ELASTIX_NO_INSTALL_RUNTIME_LIBRARIES enabled requires ELASTIX_NO_INSTALL_DEVELOPMENT enabled") + endif() add_subdirectory(KNN) target_include_directories(KNNGraphAlphaMutualInformationMetric PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/KNN) diff --git a/Components/Metrics/KNNGraphAlphaMutualInformation/KNN/CMakeLists.txt b/Components/Metrics/KNNGraphAlphaMutualInformation/KNN/CMakeLists.txt index 20448f955..69345cce1 100644 --- a/Components/Metrics/KNNGraphAlphaMutualInformation/KNN/CMakeLists.txt +++ b/Components/Metrics/KNNGraphAlphaMutualInformation/KNN/CMakeLists.txt @@ -40,9 +40,3 @@ target_link_libraries(KNNlib ANNlib ${ITK_LIBRARIES}) # Group in IDE's like Visual Studio set_property(TARGET KNNlib PROPERTY FOLDER "libraries") - -install(TARGETS KNNlib - ARCHIVE DESTINATION ${ELASTIX_ARCHIVE_DIR} - LIBRARY DESTINATION ${ELASTIX_LIBRARY_DIR} - RUNTIME DESTINATION ${ELASTIX_RUNTIME_DIR} - COMPONENT RuntimeLibraries) diff --git a/Components/Metrics/KNNGraphAlphaMutualInformation/KNN/ann_1.1/CMakeLists.txt b/Components/Metrics/KNNGraphAlphaMutualInformation/KNN/ann_1.1/CMakeLists.txt index a3d7c2f57..597b35bea 100644 --- a/Components/Metrics/KNNGraphAlphaMutualInformation/KNN/ann_1.1/CMakeLists.txt +++ b/Components/Metrics/KNNGraphAlphaMutualInformation/KNN/ann_1.1/CMakeLists.txt @@ -48,10 +48,3 @@ generate_export_header(ANNlib # Group in IDE's like Visual Studio set_property(TARGET ANNlib PROPERTY FOLDER "libraries") - -# Install -install(TARGETS ANNlib - ARCHIVE DESTINATION ${ELASTIX_ARCHIVE_DIR} - LIBRARY DESTINATION ${ELASTIX_LIBRARY_DIR} - RUNTIME DESTINATION ${ELASTIX_RUNTIME_DIR} - COMPONENT RuntimeLibraries) diff --git a/Core/CMakeLists.txt b/Core/CMakeLists.txt index 2788f8ad0..8fcad7a8c 100644 --- a/Core/CMakeLists.txt +++ b/Core/CMakeLists.txt @@ -93,10 +93,14 @@ source_group("ProgressCommand" FILES ${ProgressCommandFiles}) configure_file( elxVersionMacros.h.in elxVersionMacros.h) - -install(FILES - ${CMAKE_CURRENT_BINARY_DIR}/elxVersionMacros.h - DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Core) + +if(NOT ELASTIX_NO_INSTALL_DEVELOPMENT) + install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/elxVersionMacros.h + DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Core + COMPONENT Development + ) +endif() #--------------------------------------------------------------------- # Originally based on the answer by Naszta at @@ -244,26 +248,32 @@ if(NOT WIN32) PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib:${ITK_DIR}") endif() -install(TARGETS elastix_exe transformix_exe elastix_lib transformix_lib elxCore - ARCHIVE DESTINATION ${ELASTIX_ARCHIVE_DIR} - LIBRARY DESTINATION ${ELASTIX_LIBRARY_DIR} - RUNTIME DESTINATION ${ELASTIX_RUNTIME_DIR} - COMPONENT RuntimeLibraries) +if(NOT ELASTIX_NO_INSTALL_EXECUTABLES) + install(TARGETS elastix_exe transformix_exe + ARCHIVE DESTINATION ${ELASTIX_ARCHIVE_DIR} + LIBRARY DESTINATION ${ELASTIX_LIBRARY_DIR} + RUNTIME DESTINATION ${ELASTIX_RUNTIME_DIR} + COMPONENT Executables) +endif() # Install all header files. -install(DIRECTORY - ${elastix_SOURCE_DIR}/Common - ${elastix_SOURCE_DIR}/Core - ${elastix_SOURCE_DIR}/Components - DESTINATION ${ELASTIX_INCLUDE_DIR} - FILES_MATCHING PATTERN "*.h" PATTERN "*.hxx") -install(FILES - ${elastix_BINARY_DIR}/elxInstallComponentFunctionCalls.h - ${elastix_BINARY_DIR}/elxInstallComponentFunctionDeclarations.h - ${elastix_BINARY_DIR}/elxSupportedImageTypes.h - ${elastix_BINARY_DIR}/ITKFactoryRegistration/itkImageIOFactoryRegisterManager.h - ${elastix_BINARY_DIR}/ITKFactoryRegistration/itkTransformIOFactoryRegisterManager.h - DESTINATION ${ELASTIX_INCLUDE_DIR}) +if(NOT ELASTIX_NO_INSTALL_DEVELOPMENT) + install(DIRECTORY + ${elastix_SOURCE_DIR}/Common + ${elastix_SOURCE_DIR}/Core + ${elastix_SOURCE_DIR}/Components + DESTINATION ${ELASTIX_INCLUDE_DIR} + COMPONENT Development + FILES_MATCHING PATTERN "*.h" PATTERN "*.hxx") + install(FILES + ${elastix_BINARY_DIR}/elxInstallComponentFunctionCalls.h + ${elastix_BINARY_DIR}/elxInstallComponentFunctionDeclarations.h + ${elastix_BINARY_DIR}/elxSupportedImageTypes.h + ${elastix_BINARY_DIR}/ITKFactoryRegistration/itkImageIOFactoryRegisterManager.h + ${elastix_BINARY_DIR}/ITKFactoryRegistration/itkTransformIOFactoryRegisterManager.h + DESTINATION ${ELASTIX_INCLUDE_DIR} + COMPONENT Development) +endif() #--------------------------------------------------------------------- # The Core/Install directory contains a CMakeLists file for