Skip to content

[Threads, Boost] Option to create IMPORTED targets with GLOBAL scope

Deniz Bahadir requested to merge dbahadir/cmake:global-imported-targets into master

Currently, when using find_package to find Threads or Boost the created IMPORTED targets (Threads::Threads and Boost::...) have local scope.

This merge-request provides a way to tell the FindThreads.cmake and FindBoost.cmake scripts to create their IMPORTED targets with the additional GLOBAL flag.

Finding Threads with global imported target:

set (THREADS_MAKE_GLOBAL_TARGET TRUE)
find_package(Threads)
# Creates target Threads::Threads with global scope.

Finding Boost.Thread with global imported target:

set (Boost_MAKE_GLOBAL_TARGETS TRUE)
find_package(Boost COMPONENT thread)
# Creates i.a. target Boost::thread with global scope and its dependency
# targets with global scope, too. (One of these is Threads::Threads.)

Note: This merge-request requires !1220 (merged) to be merged first.

Merge request reports