I'm using CMake 3.8.2 and a custom build Boost 1.64 on travis. I set BOOST_ROOT
CMake variable to the prefix where I installed boost. However it still keeps picking the wrong libraries (system installed ones) although it finds my headers.
I tried to debug everything I could but failed to find the reason. Any Ideas why CMake picks the wrong libs?
From https://travis-ci.com/Return-To-The-Roots/s25client/builds/96509387:
ls -la "${BOOST_DIR}/lib"
total 37952 drwxr-xr-x 17 travis staff 578 Jan 5 16:20 . drwxr-xr-x 4 travis staff 136 Jan 5 16:18 ..
-rw-r--r-- 1 travis staff 259576 Jan 7 18:20 libboost_chrono.a
-rwxr-xr-x 1 travis staff 18656 Jan 7 18:20 libboost_chrono.dylib
-rwxr-xr-x 1 travis staff 132152 Jan 7 18:19 libboost_filesystem.dylib
-rwxr-xr-x 1 travis staff 151976 Jan 7 18:19 libboost_iostreams.dylib
-rwxr-xr-x 1 travis staff 768636 Jan 7 18:19 libboost_locale.dylib
-rwxr-xr-x 1 travis staff 82192 Jan 7 18:20 libboost_prg_exec_monitor.dylib
-rwxr-xr-x 1 travis staff 572724 Jan 7 18:19 libboost_program_options.dylib
-rwxr-xr-x 1 travis staff 1243824 Jan 7 18:20 libboost_regex.dylib
-rw-r--r-- 1 travis staff 103008 Jan 7 18:20 libboost_system.a
-rwxr-xr-x 1 travis staff 24932 Jan 7 18:18 libboost_system.dylib
-rw-r--r-- 1 travis staff 14620656 Jan 7 18:21 libboost_test_exec_monitor.a
-rwxr-xr-x 1 travis staff 160108 Jan 7 18:20 libboost_thread.dylib
-rw-r--r-- 1 travis staff 285880 Jan 7 18:20 libboost_timer.a
-rwxr-xr-x 1 travis staff 48080 Jan 7 18:20 libboost_timer.dylib
-rwxr-xr-x 1 travis staff 925444 Jan 7 18:20 libboost_unit_test_framework.dylib
-- [ /Users/travis/build/Return-To-The-Roots/s25client/deps/cmakeosx/share/cmake-3.8/Modules/FindBoost.cmake:1171 ] _boost_INCLUDE_SEARCH_DIRS = /Users/travis/build/Return-To-The-Roots/s25client/deps/boost1.64.0/include;/Users/travis/build/Return-To-The-Roots/s25client/deps/boost1.64.0;PATHS;C:/boost/include;C:/boost;/sw/local/include
-- [ /Users/travis/build/Return-To-The-Roots/s25client/deps/cmakeosx/share/cmake-3.8/Modules/FindBoost.cmake:1421 ] _boost_LIBRARY_SEARCH_DIRS_RELEASE = /Users/travis/build/Return-To-The-Roots/s25client/deps/boost1.64.0/lib;/Users/travis/build/Return-To-The-Roots/s25client/deps/boost1.64.0/stage/lib;/Users/travis/build/Return-To-The-Roots/s25client/deps/boost1.64.0/include/lib;/Users/travis/build/Return-To-The-Roots/s25client/deps/boost1.64.0/include/../lib;/Users/travis/build/Return-To-The-Roots/s25client/deps/boost1.64.0/include/stage/lib;PATHS;C:/boost/lib;C:/boost;/sw/local/lib_boost_LIBRARY_SEARCH_DIRS_DEBUG
= /Users/travis/build/Return-To-The-Roots/s25client/deps/boost1.64.0/lib;/Users/travis/build/Return-To-The-Roots/s25client/deps/boost1.64.0/stage/lib;/Users/travis/build/Return-To-The-Roots/s25client/deps/boost1.64.0/include/lib;/Users/travis/build/Return-To-The-Roots/s25client/deps/boost1.64.0/include/../lib;/Users/travis/build/Return-To-The-Roots/s25client/deps/boost1.64.0/include/stage/lib;PATHS;C:/boost/lib;C:/boost;/sw/local/lib
-- [ /Users/travis/build/Return-To-The-Roots/s25client/deps/cmakeosx/share/cmake-3.8/Modules/FindBoost.cmake:1567 ] Searching for FILESYSTEM_LIBRARY_RELEASE: boost_filesystem-mt-1_64;boost_filesystem-mt;boost_filesystem
-- [ /Users/travis/build/Return-To-The-Roots/s25client/deps/cmakeosx/share/cmake-3.8/Modules/FindBoost.cmake:365 ] Boost_LIBRARY_DIR_RELEASE = /usr/local/lib
_boost_LIBRARY_SEARCH_DIRS_RELEASE = /usr/local/lib;NO_DEFAULT_PATH;NO_CMAKE_FIND_ROOT_PATH
Boost_FILESYSTEM_LIBRARY_DEBUG:FILEPATH=/usr/local/lib/libboost_filesystem-mt.a
Looking into FindBoost of CMake 3.8.2 it leads to find_library
to be ultimately called like:
find_library(result_var
NAMES boost_filesystem-mt-1_64;boost_filesystem-mt;boost_filesystem
HINTS /Users/travis/build/Return-To-The-Roots/s25client/deps/boost1.64.0/lib;<more paths>
NAMES_PER_DIR
DOC "${_boost_docstring_release}"
)
If this finds /usr/local/lib/libboost_filesystem-mt.a
it HAS TO find my custom library which is in the first HINTS option and NAMES_PER_DIR is specified. I double-checked CMAKE_PREFIX_PATH, CMAKE_LIBRARY_PATH and CMAKE_FRAMEWORK_PATH and all are empty.
So what is happening here?
To clarify the difference to e.g. How can I get CMake to find my alternative Boost installation?:
- I'm using
cmake .... -DBOOST_ROOT=$BOOST_DIR
- It does find the headers and is not using e.g. the Boost.CMake module
- It has "my" path first in the HINTS of
find_library
andNAMES_PER_DIR
should mean it finds my libs first, but it does not.