MantisBT - CMake
View Issue Details
0016020CMakeCMakepublic2016-03-14 22:002016-06-10 14:21
Tom Jakubowski 
Roger Leigh 
normalmajoralways
closedfixed 
CMake 3.5 
CMake 3.5.1CMake 3.5.1 
0016020: FindBoost "Automatically add missing component dependencies" fails with header-only libraries
If only some separately-compiled Boost libraries are installed, so that Boost components like Boost.Atomic and Boost.DateTime are used header-only, find_package(Boost REQUIRED COMPONENTS thread) will fail with:

    :1647 (message):
      Unable to find the requested Boost libraries.

      Boost version: 1.56.0

      Boost include path: /opt/foo/deps-64-10/include

      Could not find the following Boost libraries:

              boost_atomic
              boost_chrono
              boost_date_time

If a full installation of Boost 1.56, with all optional separately-compiled libraries, is used instead, then the FindBoost() call succeeds.

This is a regression from CMake 3.4. It seems like https://github.com/Kitware/CMake/commit/01c80acdbdadf3811bc0a6cab0c28469a4e9f5b7 [^] is probably responsible.

Also related to bug 15767.
No tags attached.
related to 0016013closed Roger Leigh FindBoost: iostreams depends on regex [3.5 regression] 
Issue History
2016-03-14 22:00Tom JakubowskiNew Issue
2016-03-15 08:56Brad KingAssigned To => Roger Leigh
2016-03-15 08:56Brad KingStatusnew => assigned
2016-03-15 08:56Brad KingRelationship addedrelated to 0016013
2016-03-15 10:03Brad KingNote Added: 0040692
2016-03-15 10:05Brad KingTarget Version => CMake 3.5.1
2016-03-16 13:13Brad KingNote Added: 0040700
2016-03-16 13:17Brad KingNote Added: 0040702
2016-03-16 13:17Brad KingStatusassigned => resolved
2016-03-16 13:17Brad KingResolutionopen => fixed
2016-03-16 13:17Brad KingFixed in Version => CMake 3.5.1
2016-06-10 14:21Kitware RobotNote Added: 0041225
2016-06-10 14:21Kitware RobotStatusresolved => closed

Notes
(0040692)
Brad King   
2016-03-15 10:03   
Does the change linked in 0016013:0040691 address this?
(0040700)
Brad King   
2016-03-16 13:13   
I've reproduced this error as reported in the description. The change linked in 0016013:0040691 *does* fix it.

In the described environment, however, the FindBoost.Test test case in CMake fails with errors like:

 CMake Error at CMakeLists.txt:7 (add_executable):
   Target "test_boost_tgt" links to target "Boost::chrono" but the target was
   not found. Perhaps a find_package() call is missing for an IMPORTED
   target, or an ALIAS target is missing?

 CMake Error at CMakeLists.txt:7 (add_executable):
   Target "test_boost_tgt" links to target "Boost::date_time" but the target
   was not found. Perhaps a find_package() call is missing for an IMPORTED
   target, or an ALIAS target is missing?

 CMake Error at CMakeLists.txt:7 (add_executable):
   Target "test_boost_tgt" links to target "Boost::atomic" but the target was
   not found. Perhaps a find_package() call is missing for an IMPORTED
   target, or an ALIAS target is missing?

This is because the Boost::thread imported target still records that it depends on the other targets even though they were never created.

This is tricky because when using the Boost::thread imported target we have no way to indicate whether we want the header-only part or to really link to the library. Currently CMake is assuming the latter. Perhaps that is okay because for header-only usage one really only needs the include directory and does not need all the imported targets to get it.
(0040702)
Brad King   
2016-03-16 13:17   
The change linked in 0016013:0040691 has been merged to the 'release' branch for inclusion in CMake 3.5.1. That resolves the issue raised here.

Further discussion raised in 0016020:0040700 would be better held on the mailing list if the status quo is not sufficient.
(0041225)
Kitware Robot   
2016-06-10 14:21   
This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.