Skip to content

Commit

Permalink
Move -install project chaining to a more common place (fixes latest)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Eilemann authored and Stefan Eilemann committed Jun 8, 2017
1 parent 7ab5af2 commit 95f90da
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# git master

* [556](https://github.com/Eyescale/CMake/pull/556):
Fix rare bug with project-install missing dependencies
* [555](https://github.com/Eyescale/CMake/pull/555):
Add missing defines to version.h to ease usage w/o the need for linking

Expand Down
6 changes: 0 additions & 6 deletions Common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,6 @@ if(NOT TARGET ${PROJECT_NAME}-all)
set_target_properties(${PROJECT_NAME}-all PROPERTIES FOLDER ${PROJECT_NAME})
endif()

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)

set(COMMON_DOC_DIR share/${PROJECT_NAME}/doc)

include(ChoosePython) # Must be before any find_package to python
Expand Down
28 changes: 28 additions & 0 deletions CommonInstallProject.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright (c) 2017 Stefan.Eilemann@epfl.ch
#
# Generates ${PROJECT_NAME}-install rule. reentrant, to be called by every
# module depending on ${PROJECT_NAME}-install.
#
# 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()

# redo dependency chaining each time: a new common_find_package might have been called
string(REPLACE " " ";" __deps "${${PROJECT_NAME}_FIND_PACKAGES_FOUND}") # string-to-list
foreach(__dep ${__deps})
if(TARGET ${PROJECT_NAME}-install AND TARGET ${__dep}-install)
add_dependencies(${PROJECT_NAME}-install ${__dep}-install)
endif()
endforeach()
2 changes: 2 additions & 0 deletions CommonSmokeTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
# - <project>-smoketests: run all smoke tests of the given (sub)project
# - <Target>-smoketest: run the given smoke test

include(CommonInstallProject)

if(NOT TARGET smoketests)
add_custom_target(smoketests)
set_target_properties(smoketests PROPERTIES
Expand Down
1 change: 1 addition & 0 deletions DoxygenRule.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ if(NOT TARGET ${PROJECT_NAME}-all)
endif()

include(CommonDate)
include(CommonInstallProject)
if(NOT GIT_DOCUMENTATION_REPO)
include(GithubInfo)
set(GIT_DOCUMENTATION_REPO ${GIT_ORIGIN_ORG})
Expand Down
3 changes: 0 additions & 3 deletions SubProject.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,6 @@ macro(git_subproject name url tag)
get_property(__included GLOBAL PROPERTY ${name}_IS_SUBPROJECT)
if(__included)
list(APPEND __subprojects "${name} ${url} ${tag}")
if(TARGET ${PROJECT_NAME}-install AND TARGET ${name}-install)
add_dependencies(${PROJECT_NAME}-install ${name}-install)
endif()
endif()
endmacro()

Expand Down

0 comments on commit 95f90da

Please sign in to comment.