MantisBT - CMake
View Issue Details
0011019CMakeModulespublic2010-07-21 08:462010-11-09 22:57
Tom Vercauteren 
Philip Lowman 
normalminoralways
closedfixed 
CMake-2-8 
CMake 2.8.3CMake 2.8.3 
0011019: FindBoost: Potential incoherent behavior when BOOST_ROOT is set and there is a boost installation in system directories
This is a duplicate of bug 9447 but since I am not the initial reporter, I cannot reopen it.

I have a system installation of boost 1.40 for my package manager on ubuntu but want my project to be compiled against a local boost package (version 1.42).

By default, If I only specify BOOST_ROOT, FindBoost will get the include dir correctly but will take the libraries from /usr/lib.

The reason is because my local boost copy does not have the "-mt" libraries, e.g.
- local has libboost_regex.a libboost_regex.so libboost_regex.so.1.42.0
- system has /usr/lib/libboost_regex.a /usr/lib/libboost_regex-mt.so /usr/lib/libboost_regex.so.1.40.0 /usr/lib/libboost_regex-mt.a /usr/lib/libboost_regex.so

Setting Boost_USE_MULTITHREADED to OFF solves the problem.

I do however still consider this to be a bug since no warning is issued and the advice in bug 9447 did not solve my problem.
I had the following output with Boost_DEBUG:

-- [ BLABLA/FindBoost.cmake:373 ] Boost not in cache
-- [ BLABLA/FindBoost.cmake:376 ] _boost_TEST_VERSIONS = 1.41.0;1.41;1.40.0;1.40;1.39.0;1.39;1.38.0;1.38;1.37.0;1.37;1.36.1;1.36.0;1.36;1.35.1;1.35.0;1.35;1.34.1;1.34.0;1.34;1.33.1;1.33.0;1.33
-- [ BLABLA/FindBoost.cmake:378 ] Boost_USE_MULTITHREADED = TRUE
-- [ BLABLA/FindBoost.cmake:380 ] Boost_USE_STATIC_LIBS =
-- [ BLABLA/FindBoost.cmake:439 ] Declared as CMake or Environmental Variables:
-- [ BLABLA/FindBoost.cmake:441 ] BOOST_ROOT = /usr/local/mkt-dev/install/boost_1_42_0
-- [ BLABLA/FindBoost.cmake:443 ] BOOST_INCLUDEDIR =
-- [ BLABLA/FindBoost.cmake:445 ] BOOST_LIBRARYDIR =
-- [ BLABLA/FindBoost.cmake:447 ] _boost_TEST_VERSIONS = 1.41.0;1.41;1.40.0;1.40;1.39.0;1.39;1.38.0;1.38;1.37.0;1.37;1.36.1;1.36.0;1.36;1.35.1;1.35.0;1.35;1.34.1;1.34.0;1.34;1.33.1;1.33.0;1.33
-- [ BLABLA/FindBoost.cmake:496 ] Include debugging info:
-- [ BLABLA/FindBoost.cmake:498 ] _boost_INCLUDE_SEARCH_DIRS = /usr/local/mkt-dev/install/boost_1_42_0/include;/usr/local/mkt-dev/install/boost_1_42_0;C:/boost/include;C:/boost;/boost/include;/boost;/sw/local/include
-- [ BLABLA/FindBoost.cmake:500 ] _boost_PATH_SUFFIXES = boost-1_41_0;boost-1_41;boost-1_40_0;boost-1_40;boost-1_39_0;boost-1_39;boost-1_38_0;boost-1_38;boost-1_37_0;boost-1_37;boost-1_36_1;boost-1_36_0;boost-1_36;boost-1_35_1;boost-1_35_0;boost-1_35;boost-1_34_1;boost-1_34_0;boost-1_34;boost-1_33_1;boost-1_33_0;boost-1_33
-- [ BLABLA/FindBoost.cmake:524 ] location of version.hpp: /usr/local/mkt-dev/install/boost_1_42_0/include/boost/version.hpp
-- [ BLABLA/FindBoost.cmake:543 ] version.hpp reveals boost 1.42.0
-- [ BLABLA/FindBoost.cmake:634 ] guessed _boost_COMPILER = -gcc44
-- [ BLABLA/FindBoost.cmake:644 ] _boost_MULTITHREADED = -mt
-- [ BLABLA/FindBoost.cmake:661 ] _boost_STATIC_TAG =
-- [ BLABLA/FindBoost.cmake:663 ] _boost_ABI_TAG = d
-- [ BLABLA/FindBoost.cmake:696 ] _boost_LIBRARIES_SEARCH_DIRS = /usr/local/mkt-dev/install/boost_1_42_0/lib;/usr/local/mkt-dev/install/boost_1_42_0/stage/lib;/usr/local/mkt-dev/install/boost_1_42_0/include/lib;/usr/local/mkt-dev/install/boost_1_42_0/include/../lib;C:/boost/lib;C:/boost;/boost/boost_1_42_0/lib;/boost/boost_1_42/lib;/boost/lib;/boost;/sw/local/lib
-- [ BLABLA/FindBoost.cmake:830 ] Boost_FOUND = TRUE
-- Boost version: 1.42.0
-- Found the following Boost libraries:
-- date_time
-- filesystem
-- iostreams
-- program_options
-- regex
-- serialization
-- signals
-- system
-- thread
-- unit_test_framework
-- python
boost
duplicate of 0008412closed Philip Lowman Setting BOOST_ROOT does not guarantee boost libraries detected outside BOOST_ROOT are the correct ones 
Issue History
2010-07-21 08:46Tom VercauterenNew Issue
2010-07-21 08:47Tom VercauterenTag Attached: boost
2010-08-11 23:42Philip LowmanStatusnew => assigned
2010-08-11 23:42Philip LowmanAssigned To => Philip Lowman
2010-08-11 23:48Philip LowmanNote Added: 0021724
2010-08-12 01:32Tom VercauterenNote Added: 0021725
2010-08-18 23:26Philip LowmanNote Added: 0021818
2010-09-08 23:43Philip LowmanNote Added: 0022154
2010-09-10 08:40Philip LowmanETAnone => < 1 day
2010-09-10 08:40Philip LowmanTarget Version => CMake 2.8.3
2010-09-12 22:31Philip LowmanNote Added: 0022202
2010-09-12 22:31Philip LowmanRelationship addedduplicate of 0008412
2010-09-12 22:31Philip LowmanDuplicate ID0 => 8412
2010-09-12 22:31Philip LowmanStatusassigned => resolved
2010-09-12 22:31Philip LowmanFixed in Version => CMake 2.8.3
2010-09-12 22:31Philip LowmanResolutionopen => fixed
2010-11-09 22:57Philip LowmanStatusresolved => closed

Notes
(0021724)
Philip Lowman   
2010-08-11 23:48   
If you want FindBoost to discover boost libraries without -mt, the proper thing to do is to set Boost_USE_MULTITHREADED to OFF (it defaults to ON if it's not set).

The issue of FindBoost searching outside of BOOST_ROOT if it can't find stuff there first is how it was written. I'm pretty sure this was intentional but I'm not positive since I wasn't the author. I don't think it can be safely changed now. Would it help if I added an option that excludes searching outside of the BOOST_ROOT directory completely? This way people could enable it if they are 100% sure they don't want their builds using a system boost library?
(0021725)
Tom Vercauteren   
2010-08-12 01:32   
Being able to constrain the search in BOOST_ROOT would definitely be a good thing.

Also, it would be nice if a warning was issued when the include and libraries are found in different directories. This may help avoid weird situations when the boost versions are different in these directories.

What I forgot to mention is that even when Boost_USE_MULTITHREADED is not set (i.e. it is ON), FindBoost was able to find my local boost libraries (without the -mt suffix) as long as no system installation of Boost was available.
(0021818)
Philip Lowman   
2010-08-18 23:26   
Ok. To resolve this then (don't have time this moment so I'm logging this here for later).

1. I will add constrain support to FindBoost (optionally enabled via a variable)

2. I will try to come up with a way to determine if the detected libraries are totally outside the boost install path. Issuing a warning seems reasonable in this case. This code would need to be well tested and probably would be best if the warning only occurred once.

3. I will try to reproduce your case where single-threaded boost libraries are present only and FindBoost locates them.
(0022154)
Philip Lowman   
2010-09-08 23:43   
Will be fixed with Boost_NO_SYSTEM_PATHS
(0022202)
Philip Lowman   
2010-09-12 22:31   
Fix will be in CMake 2.8.3 RC1