forked from Eyescale/CMake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CommonInstallProject.cmake
29 lines (27 loc) · 1.28 KB
/
CommonInstallProject.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Copyright (c) 2017 [email protected]
#
# Generates ${PROJECT_NAME}-install rule. Adds common_add_install_dependencies
# function which takes a list of dependencies and adds their install target to
# the project install, if available.
#
# This rule is for targets which depend on the installed artefacts, e.g.,
# doxygen and smoke tests. CMake does not provide this, so this is a workaround.
# install naturally depends on all, which depends on all common_library and
# common_application targets. Furthermore, ${PROJECT_NAME}-install depends on
# all subprojects which have an install rule, so that all necessary artefacts in
# a superproject build are installed. The list of subprojects is extracted from
# ${PROJECT_NAME}_FIND_PACKAGES_FOUND, set by common_find_package.
if(NOT TARGET ${PROJECT_NAME}-install)
add_custom_target(${PROJECT_NAME}-install
${CMAKE_COMMAND} -P ${PROJECT_BINARY_DIR}/cmake_install.cmake
DEPENDS ${PROJECT_NAME}-all)
set_target_properties(${PROJECT_NAME}-install PROPERTIES
EXCLUDE_FROM_DEFAULT_BUILD ON)
endif()
function(COMMON_ADD_INSTALL_DEPENDENCIES)
foreach(__dep ${ARGN})
if(TARGET ${PROJECT_NAME}-install AND TARGET ${__dep}-install)
add_dependencies(${PROJECT_NAME}-install ${__dep}-install)
endif()
endforeach()
endfunction()