MantisBT - CMake
View Issue Details
0015702CMakeModulespublic2015-08-17 10:172016-06-10 14:21
John Harris 
Brad King 
normalminoralways
closedfixed 
LinuxCentOS
CMake 3.3 
CMake 3.6CMake 3.6 
0015702: FindBoost ignores Boost_NO_SYSTEM_PATH in debug builds
It seems the FindBoost module in Clion 1.1's new cmake ignores the Boost_NO_SYSTEM_PATHS for a Debug build, selecting /usr/lib64 instead of the correct library path, resulting in link errors.

I had to do this to make the Debug configuration work:

Work around FindBoost locating debug libs in the /usr/lib64 instead of the custom installation
SET(Boost_LIBRARY_DIR_DEBUG $ENV{HOME}/usr/local/boost/lib CACHE PATH "Forced boost lib dir for debug" FORCE)
SET(Boost_PROGRAM_OPTIONS_LIBRARY_DEBUG $ENV{HOME}/usr/local/boost/lib/libboost_program_options-gcc49-mt-1_56.so CACHE FILEPATH "Forced boost program_options lib dir for debug" FORCE)


Here is the cmake output showing the incorrect Boost_LIBRARY_DIR_DEBUG

[ /home/jharris/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:549 ] _boost_TEST_VERSIONS = 1.56.0;1.56
– [ /home/jharris/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:551 ] Boost_USE_MULTITHREADED = ON
– [ /home/jharris/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:553 ] Boost_USE_STATIC_LIBS =
– [ /home/jharris/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:555 ] Boost_USE_STATIC_RUNTIME =
– [ /home/jharris/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:557 ] Boost_ADDITIONAL_VERSIONS =
– [ /home/jharris/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:559 ] Boost_NO_SYSTEM_PATHS = ON
– [ /home/jharris/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:611 ] Declared as CMake or Environmental Variables:
– [ /home/jharris/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:613 ] BOOST_ROOT = /home/jharris/usr/local/boost
– [ /home/jharris/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:615 ] BOOST_INCLUDEDIR =
– [ /home/jharris/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:617 ] BOOST_LIBRARYDIR =
– [ /home/jharris/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:619 ] _boost_TEST_VERSIONS = 1.56.0;1.56
– [ /home/jharris/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:712 ] location of version.hpp: /home/jharris/usr/local/boost/include/boost-1_56/boost/version.hpp
– [ /home/jharris/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:736 ] version.hpp reveals boost 1.56.0
– [ /home/jharris/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:822 ] guessed _boost_COMPILER = -gcc49
– [ /home/jharris/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:832 ] _boost_MULTITHREADED = -mt
– [ /home/jharris/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:875 ] _boost_RELEASE_ABI_TAG = -
– [ /home/jharris/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:877 ] _boost_DEBUG_ABI_TAG = -d
– [ /home/jharris/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:931 ] _boost_LIBRARY_SEARCH_DIRS_RELEASE = /home/jharris/usr/local/boost/lib;NO_DEFAULT_PATH;NO_CMAKE_FIND_ROOT_PATH_boost_LIBRARY_SEARCH_DIRS_DEBUG = /usr/lib64;NO_DEFAULT_PATH;NO_CMAKE_FIND_ROOT_PATH
– [ /home/jharris/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:1043 ] Searching for PROGRAM_OPTIONS_LIBRARY_RELEASE: boost_program_options-gcc49-mt-1_56;boost_program_options-gcc49-mt;boost_program_options-mt-1_56;boost_program_options-mt;boost_program_options
– [ /home/jharris/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:343 ] Boost_LIBRARY_DIR_RELEASE = /home/jharris/usr/local/boost/lib _boost_LIBRARY_SEARCH_DIRS_RELEASE = /home/jharris/usr/local/boost/lib;NO_DEFAULT_PATH;NO_CMAKE_FIND_ROOT_PATH
– [ /home/jharris/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:1085 ] Searching for PROGRAM_OPTIONS_LIBRARY_DEBUG: boost_program_options-gcc49-mt-d-1_56;boost_program_options-gcc49-mt-d;boost_program_options-mt-d-1_56;boost_program_options-mt-d;boost_program_options-mt;boost_program_options
– [ /home/jharris/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:343 ] Boost_LIBRARY_DIR_DEBUG = /usr/lib64 _boost_LIBRARY_SEARCH_DIRS_DEBUG = /usr/lib64;NO_DEFAULT_PATH;NO_CMAKE_FIND_ROOT_PATH
– [ /home/jharris/clion-1.1/bin/cmake/share/cmake-3.3/Modules/FindBoost.cmake:1151 ] Boost_FOUND = 1
– Boost version: 1.56.0
– Found the following Boost libraries:
Try to link a boost program using a custom installation of Boost in your home directory with a different, incompatible one installed by default in the Linux OS filesystem.
This worked fine until I updated to this version with the latest CLion.
No tags attached.
Issue History
2015-08-17 10:17John HarrisNew Issue
2016-05-02 11:20LCID FireNote Added: 0041006
2016-05-02 11:24Brad KingNote Added: 0041007
2016-05-02 11:41LCID FireNote Added: 0041008
2016-05-02 11:47Brad KingNote Added: 0041009
2016-05-02 12:59LCID FireNote Added: 0041010
2016-05-02 13:07Brad KingAssigned To => Brad King
2016-05-02 13:07Brad KingStatusnew => resolved
2016-05-02 13:07Brad KingResolutionopen => fixed
2016-05-02 13:07Brad KingFixed in Version => CMake 3.6
2016-05-02 13:07Brad KingTarget Version => CMake 3.6
2016-06-10 14:21Kitware RobotNote Added: 0041179
2016-06-10 14:21Kitware RobotStatusresolved => closed

Notes
(0041006)
LCID Fire   
2016-05-02 11:20   
For me on CMake 3.5.1, Boost_NO_SYSTEM_PATHS find system libraries, too. Either documentation is wrong or this is a bug.
(0041007)
Brad King   
2016-05-02 11:24   
Please run CMake with -DBoost_DEBUG=ON to get more verbose output about what FindBoost is doing.
(0041008)
LCID Fire   
2016-05-02 11:41   
It is very easy.
Do:

set( BOOST_INCLUDEDIR "nonpresent" )
set( BOOST_LIBRARYDIR "reallybad" )

set( Boost_NO_SYSTEM_PATHS ON )

find_package( Boost REQUIRED
    COMPONENTS
        filesystem
)

# This does NOT fail (see documentation). It finds filesystem in system.

I do not know, whether this is the same issue as the original post.
(0041009)
Brad King   
2016-05-02 11:47   
A change in CMake 3.3 extended what system paths are found via the environment:

 Teach find_(library|file|path) to get prefixes from PATH
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ffc06c12 [^]

That exposed the actual bug in FindBoost which is that it should not consider system environment variables either when Boost_NO_SYSTEM_PATHS is given. I've fixed that now:

 FindBoost: Fix Boost_NO_SYSTEM_PATHS to not consider environment
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5a9b2b3b [^]

Please try this fix locally to see if it resolves the issue.
(0041010)
LCID Fire   
2016-05-02 12:59   
With the fix it fails again.
(0041179)
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.