Allow disabling install targets

Might be useful if install targets cause
problems, eg. under MacOS
This commit is contained in:
Martchus 2017-07-20 01:43:10 +02:00
parent 326551ee02
commit 36b2498dd6
5 changed files with 43 additions and 29 deletions

View File

@ -65,7 +65,7 @@ set_target_properties(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX} PROPE
AUTOGEN_TARGET_DEPENDS "${AUTOGEN_DEPS}"
)
if(NOT META_NO_INSTALL_TARGETS)
if(NOT META_NO_INSTALL_TARGETS AND ENABLE_INSTALL_TARGETS)
# add install target for binary
install(TARGETS ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
RUNTIME DESTINATION bin

View File

@ -252,19 +252,29 @@ if(CLANG_SOURCE_BASED_COVERAGE_ENABLED)
endif()
endif()
# configure creation of install targets
if(NOT META_NO_INSTALL_TARGETS)
# install targets have not been disabled on project level
# check whether install targets are disabled by the user
# this might be useful since install targets seem to cause problems under MacOS
option(ENABLE_INSTALL_TARGETS "enables creation of install targets" ON)
endif()
# add install target for extra files
foreach(EXTRA_FILE ${EXTRA_FILES})
get_filename_component(EXTRA_DIR ${EXTRA_FILE} DIRECTORY)
install(
FILES ${EXTRA_FILE}
DESTINATION "share/${META_PROJECT_NAME}/${EXTRA_DIR}"
COMPONENT extra-files
)
endforeach()
if(NOT TARGET install-extra-files)
add_custom_target(install-extra-files
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=extra-files -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
)
if(NOT META_NO_INSTALL_TARGETS AND ENABLE_INSTALL_TARGETS)
foreach(EXTRA_FILE ${EXTRA_FILES})
get_filename_component(EXTRA_DIR ${EXTRA_FILE} DIRECTORY)
install(
FILES ${EXTRA_FILE}
DESTINATION "share/${META_PROJECT_NAME}/${EXTRA_DIR}"
COMPONENT extra-files
)
endforeach()
if(NOT TARGET install-extra-files)
add_custom_target(install-extra-files
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=extra-files -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
)
endif()
endif()
set(BASIC_PROJECT_CONFIG_DONE YES)

View File

@ -61,15 +61,17 @@ if(NOT NO_DOXYGEN)
add_dependencies(apidoc "${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_apidoc")
# add install target for API documentation
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/api-doc"
DESTINATION "share/${META_PROJECT_NAME}"
COMPONENT api-doc
OPTIONAL
)
if(NOT TARGET install-api-doc)
add_custom_target(install-api-doc
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=api-doc -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
if(NOT META_NO_INSTALL_TARGETS AND ENABLE_INSTALL_TARGETS)
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/api-doc"
DESTINATION "share/${META_PROJECT_NAME}"
COMPONENT api-doc
OPTIONAL
)
if(NOT TARGET install-api-doc)
add_custom_target(install-api-doc
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=api-doc -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
)
endif()
endif()
message(STATUS "Generating target for generating API documentation for ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX} with Doxygen")

View File

@ -305,7 +305,7 @@ configure_file(
)
list(APPEND PC_FILES "${CMAKE_CURRENT_BINARY_DIR}/${META_PROJECT_NAME_FOR_PC}.pc")
if(NOT META_NO_INSTALL_TARGETS)
if(NOT META_NO_INSTALL_TARGETS AND ENABLE_INSTALL_TARGETS)
# add install target for the CMake config files
install(
FILES

View File

@ -20,14 +20,16 @@ if(SHELL_COMPLETION_ENABLED)
)
# add install target bash completion
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bash-completion/completions"
DESTINATION "share/bash-completion"
COMPONENT bash-completion
)
if(NOT TARGET install-bash-completion)
add_custom_target(install-bash-completion
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=bash-completion -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
if(NOT META_NO_INSTALL_TARGETS AND ENABLE_INSTALL_TARGETS)
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bash-completion/completions"
DESTINATION "share/bash-completion"
COMPONENT bash-completion
)
if(NOT TARGET install-bash-completion)
add_custom_target(install-bash-completion
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=bash-completion -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
)
endif()
endif()
message(STATUS "Generating files for bash completion.")