MantisBT - CMake
View Issue Details
0016057CMakeCMakepublic2016-04-09 09:582016-06-10 14:21
Tatsuyuki Ishi 
Roger Leigh 
normalminoralways
closedfixed 
CMake 3.5.1 
CMake 3.6CMake 3.6 
0016057: FindBoost: No imported target when components not specified
Here's an example:
=============
project(...)
find_package(Boost REQUIRED)
add_executable(...)
target_link_libraries(... Boost::Boost)
*BOOM*
=============

But this works:
=============
find_package(Boost COMPONENTS system REQUIRED)
target_link_libraries(... Boost::Boost)
=============

This is hard to use, and should be considered as bug and fixed.
No tags attached.
Issue History
2016-04-09 09:58Tatsuyuki IshiNew Issue
2016-04-11 09:28Brad KingAssigned To => Roger Leigh
2016-04-11 09:28Brad KingStatusnew => assigned
2016-04-18 12:19Roger LeighNote Added: 0040882
2016-04-19 08:22Nils GladitzNote Added: 0040885
2016-04-19 16:37Roger LeighNote Added: 0040893
2016-04-19 16:49Nils GladitzNote Added: 0040894
2016-04-19 17:22Roger LeighNote Added: 0040895
2016-04-20 09:54Brad KingNote Added: 0040898
2016-04-20 09:54Brad KingStatusassigned => resolved
2016-04-20 09:54Brad KingResolutionopen => fixed
2016-04-20 09:54Brad KingFixed in Version => CMake 3.6
2016-04-20 09:54Brad KingTarget Version => CMake 3.6
2016-06-10 14:21Kitware RobotNote Added: 0041188
2016-06-10 14:21Kitware RobotStatusresolved => closed

Notes
(0040882)
Roger Leigh   
2016-04-18 12:19   
I looked at FindBoost.cmake to see if this is the case, but it should work if COMPONENTS is not used. It's set if Boost_FOUND is true and Boost_IMPORTED_TARGETS is true; the latter is true if a supported boost version is in use, which should be true unless you're using a truly ancient version or an unreleased version.

The patch proposed here:
https://github.com/Kitware/CMake/compare/master...rleigh-dundee:boost-import-default?expand=1 [^]
should make it get unconditionally defined. Could you possibly try it and let me know if it works for you?


Thanks,
Roger
(0040885)
Nils Gladitz   
2016-04-19 08:22   
That seems to work for me.

Boost_IMPORTED_TARGETS is unset since the function that sets it never gets called (when you don't specify components).
(0040893)
Roger Leigh   
2016-04-19 16:37   
Ah, makes sense. OK, I'll submit this shortly. By the way, in the original comment, you had

target_link_libraries(... Boost::Boost)

Note the capitalisation: it's Boost::boost.
(0040894)
Nils Gladitz   
2016-04-19 16:49   
I am not the original poster but I noticed that too :)
(0040895)
Roger Leigh   
2016-04-19 17:22   
I've merged my boost-import-default branch into next for testing, including a unit test to check that the Boost::boost target is defined when COMPONENTS was not used.

I'm not sure on the workflow for mantis here. Does the resolution get changed before or after the branch is merged? Or does anything else need doing here on my part?

Regards,
Roger
(0040898)
Brad King   
2016-04-20 09:54   
Re 0016057:0040895: Once the fix is in 'next' and you are confident it resolves the issue go ahead and mark it resolved here (but not closed).

Anyway, the fix is now in 'master':

FindBoost: Define Boost::boost for all boost versions
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2c1b720e [^]
(0041188)
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.