-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This provides ChimeraTK::<project-name> as cmake imported target. Variables <project_name>_INCLUDE_DIRS, <project_name>LIBRARY_DIRS, <project_name>_LIBRARIES, <project_name>_CXX_FLAGS, <project_name>_LINKER_FLAGS are provided for compatibility but are generated from cmake-exports where possible and cmake imported targets should be preferred. * provide function for option array conversion to be used with target_compile_options etc + FindPackage results, where findPackage results are of incorrect/old format * FindDOOCS: - DOOCS components as imported targets - clean up no longer needed tweaks - add timinglib as component - make use of log levels and respect QUIET argument * add_dependency: fail on wrong add_dependency usage this was unseen since it worked in most cases but in general does not in particular was causing trouble with imports from cppext second arg must be version number * pkgconfig exports - generated from cmake-exports - make linker flags come before libs, order is required e.g. for --no-as-needed flag - remove duplicates in output * FindGccAtomic - do not put absolute lib path in output since it was causing trouble with yocto builds. Should be in system lib paths anyway. Also, make GccAtomic variable output name more consistent.
- Loading branch information
Showing
7 changed files
with
504 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,14 @@ | |
# @PROJECT_NAME@_CXX_FLAGS : additional C++ compiler flags | ||
# @PROJECT_NAME@_LINKER_FLAGS : additional linker flags | ||
# | ||
# Note for exporting project: | ||
# If @PROJECT_NAME@ sets PROVIDES_EXPORTED_TARGETS, we also generate target EXPORTS. In this case the its CMakeLists.txt | ||
# must also have | ||
# install(TARGETS EXPORT ${PROJECT_NAME}Targets) | ||
# before. The target will be named ChimeraTK::${PROJECT_NAME} . | ||
# We keep above mentioned return variables for compatibility, but finally, when all projects use imported targets, | ||
# all execept _FOUND and _VERSION will be superfluous. | ||
# | ||
# @author Martin Killenberg, DESY | ||
# | ||
####################################################################################################################### | ||
|
@@ -27,42 +35,73 @@ | |
# | ||
####################################################################################################################### | ||
|
||
# The library itself must be "searched" using the FIND_LIBRARY command in the known install directory, to set | ||
# the variable properly | ||
FIND_LIBRARY(@PROJECT_NAME@_LIBRARY @PROJECT_NAME@ | ||
@CMAKE_INSTALL_PREFIX@/lib | ||
NO_DEFAULT_PATH | ||
) | ||
# In case of packages with components, loading dependencies can cause trouble if required component list are differ. | ||
# E.g. if Boost is required from the project, and also required from the dependency, but with less components, | ||
# and the dependency is resolved later, then Boost_LIBRARIES content will be different than expected. | ||
# To protect against this, save state and restore it later. | ||
# Since imported targets are never unloaded, the loaded dependency should still work. | ||
set(Boost_LIBRARIES_savedState_@PROJECT_NAME@ ${Boost_LIBRARIES}) | ||
|
||
# this code loads public dependencies | ||
@@PROJECT_NAME@_PUBLIC_DEPENDENCIES_L@ | ||
set(Boost_LIBRARIES ${Boost_LIBRARIES_savedState_@PROJECT_NAME@}) | ||
|
||
# Since this file is already part of the installation to be found, the configuration can be hard-coded at | ||
# installation time | ||
set(@PROJECT_NAME@_VERSION "@@PROJECT_NAME@_SOVERSION@") | ||
set(@PROJECT_NAME@_INCLUDE_DIRS @@PROJECT_NAME@_INCLUDE_DIRS@) | ||
set(@PROJECT_NAME@_LIBRARY_DIRS @@PROJECT_NAME@_LIBRARY_DIRS@) | ||
if(@@PROJECT_NAME@_HAS_LIBRARY@) | ||
set(@PROJECT_NAME@_LIBRARIES ${@PROJECT_NAME@_LIBRARY} @@PROJECT_NAME@_LIBRARIES@) | ||
else() | ||
set(@PROJECT_NAME@_LIBRARIES @@PROJECT_NAME@_LIBRARIES@) | ||
endif() | ||
set(@PROJECT_NAME@_CXX_FLAGS "@@PROJECT_NAME@_CXX_FLAGS@") | ||
set(@PROJECT_NAME@_LINKER_FLAGS "@@PROJECT_NAME@_LINKER_FLAGS@ @@PROJECT_NAME@_LINK_FLAGS@") | ||
set(@PROJECT_NAME@_LINK_FLAGS "@@PROJECT_NAME@_LINKER_FLAGS@ @@PROJECT_NAME@_LINK_FLAGS@") | ||
set(@PROJECT_NAME@_PREFIX "@CMAKE_INSTALL_PREFIX@") | ||
|
||
# Use a macro provided by CMake to check if all the listed arguments are valid and set @PROJECT_NAME@_FOUND accordingly. | ||
# This is mainly important to check the version. | ||
set(@PROJECT_NAME@_FOUND 0) | ||
include(FindPackageHandleStandardArgs) | ||
|
||
# The FOUND_VAR option in FIND_PACKAGE_HANDLE_STANDARD_ARGS was introduced in cmake-2.8.11, but Ubuntu 12.04 has cmake-2.8.7 only. | ||
# Thus we use a work around here for older cmake versions. | ||
if("${CMAKE_VERSION}" VERSION_LESS 2.8.11) | ||
# The old version always provides a variable with upper case project name, so we just copy that | ||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(@PROJECT_NAME@ REQUIRED_VARS @PROJECT_NAME@_PREFIX VERSION_VAR @PROJECT_NAME@_VERSION) | ||
STRING(TOUPPER "@PROJECT_NAME@" PROJECT_NAME_UPPERCASE) | ||
set(@PROJECT_NAME@_FOUND ${${PROJECT_NAME_UPPERCASE}_FOUND}) | ||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(@PROJECT_NAME@ REQUIRED_VARS @PROJECT_NAME@_PREFIX VERSION_VAR @PROJECT_NAME@_VERSION FOUND_VAR @PROJECT_NAME@_FOUND) | ||
|
||
# switch for exported target. We don't do this automatically, because the calling CMakeLists.txt | ||
# first must be edited so that it properly defines PUBLIC set of compile and link options | ||
if(@PROVIDES_EXPORTED_TARGETS@) | ||
|
||
@PACKAGE_INIT@ | ||
|
||
# include cmake's auto-generated exports file | ||
include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]") | ||
# this will set ${PROJECT_NAME}_FOUND if required components are missing | ||
check_required_components(@PROJECT_NAME@) | ||
|
||
else() | ||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(@PROJECT_NAME@ REQUIRED_VARS @PROJECT_NAME@_PREFIX VERSION_VAR @PROJECT_NAME@_VERSION FOUND_VAR @PROJECT_NAME@_FOUND) | ||
endif() | ||
if(@@PROJECT_NAME@_HAS_LIBRARY@) | ||
# has true compiled library as output | ||
# The library itself must be "searched" using the FIND_LIBRARY command in the known install directory, to set | ||
# the variable properly | ||
FIND_LIBRARY(@PROJECT_NAME@_LIBRARY @PROJECT_NAME@ | ||
@CMAKE_INSTALL_PREFIX@/lib | ||
NO_DEFAULT_PATH | ||
) | ||
if(NOT @PROJECT_NAME@_LIBRARY) | ||
set(@PROJECT_NAME@_FOUND FALSE) | ||
message(SEND_ERROR "FIND_LIBRARY returned error: ${@PROJECT_NAME@_LIBRARY}") | ||
else() | ||
# prepend it to lib list | ||
set(@PROJECT_NAME@_LIBRARIES ${@PROJECT_NAME@_LIBRARY} ${@PROJECT_NAME@_LIBRARIES}) | ||
endif() | ||
endif() | ||
endif() | ||
|
||
# Compatibility layer definitions. | ||
# The following variables are generated automatically for projects supporting cmake-exports. | ||
# Otherwise, values must be provided as inputs to create_cmake_config_files. | ||
# The types of generated lists are precisely as in old DeviceAccess config | ||
# inc dirs, lib dirs, libs are ";" separated | ||
# cxx flags, link flags are " " separated | ||
# ";" separated | ||
set(@PROJECT_NAME@_INCLUDE_DIRS @@PROJECT_NAME@_INCLUDE_DIRS@) | ||
# ";" separated | ||
set(@PROJECT_NAME@_LIBRARY_DIRS @@PROJECT_NAME@_LIBRARY_DIRS@) | ||
# ";" separated | ||
set(@PROJECT_NAME@_LIBRARIES ${@PROJECT_NAME@_LIBRARIES} @@PROJECT_NAME@_LIBRARIES@) | ||
# " " separated | ||
set(@PROJECT_NAME@_CXX_FLAGS "@@PROJECT_NAME@_CXX_FLAGS@") | ||
# " " separated | ||
set(@PROJECT_NAME@_LINKER_FLAGS "@@PROJECT_NAME@_LINKER_FLAGS@ @@PROJECT_NAME@_LINK_FLAGS@") | ||
# " " separated | ||
set(@PROJECT_NAME@_LINK_FLAGS "@@PROJECT_NAME@_LINKER_FLAGS@ @@PROJECT_NAME@_LINK_FLAGS@") |
Oops, something went wrong.