The reason is that ONLY really does mean: “only look in the CMAKE_FIND_ROOT_PATH, and don’t look anywhere else”. This can be useful when cross-compiling, as it ensures that you can strictly control the location(s) where system headers are found, and not accidentally find them on the host system. It would be bad if, e.g., you were trying to target an embedded device and CMake and/or the compiler used the system headers from your host Linux machine.
Having said that, I disabled the ONLY option when I cross-compile for iOS and Android, as I found it too limiting. I have cross-compiled dependencies (including Boost) in locations outside of the CMAKE_FIND_ROOT_PATH, and I didn’t want to relocate them all inside CMAKE_FIND_ROOT_PATH to satisfy the ONLY option. Parag Chandra Senior Software Engineer, Mobile Team Mobile: +1.919.824.1410 [https://www.ionicsecurity.com/IonicSigHz.png]<https://ionic.com> Ionic Security Inc. 1170 Peachtree St. NE STE 400, Atlanta, GA 30309 From: CMake <cmake-boun...@cmake.org<mailto:cmake-boun...@cmake.org>> on behalf of Zac Bergquist <zbergquis...@gmail.com<mailto:zbergquis...@gmail.com>> Date: Monday, December 7, 2015 at 1:56 PM To: Cmake Mailing List <cmake@cmake.org<mailto:cmake@cmake.org>> Subject: Re: [CMake] CMake not finding boost headers It turns out I missed some important information. I am cross compiling, and my toolchain file sets CMAKE_FIND_ROOT_PATH_MODE_INCLUDE to ONLY. If I change ONLY to BOTH, CMake succesfully locates the Boost headers. I'm not sure if this is the correct solution though. Why would setting this to ONLY prevent CMake from searching outside CMAKE_FIND_ROOT_PATH? On Mon, Dec 7, 2015 at 1:44 PM, Zac Bergquist <zbergquis...@gmail.com<mailto:zbergquis...@gmail.com>> wrote: I'm stuck on what seems like a rather simple problem. I've got this in my CMakeLists.txt set(BOOST_INCLUDEDIR ${CMAKE_CURRENT_LIST_DIR}/boost_1_59_0) set(Boost_DEBUG 1) find_package(Boost 1.59.0 EXACT REQUIRED) The boost_1_59_0 I'm pointing it to contains the Boost source straight from the 1.59.0 release. I've tried both CMake 3.3.1 and 3.4.1. When I run CMake, I get the "Unable to find the Boost header files" error. Here's some of the debug output: -- [ FindBoost.cmake:551 ] _boost_TEST_VERSIONS = 1.59.0;1.59 -- [ FindBoost.cmake:553 ] Boost_USE_MULTITHREADED = TRUE -- [ FindBoost.cmake:555 ] Boost_USE_STATIC_LIBS = -- [ FindBoost.cmake:557 ] Boost_USE_STATIC_RUNTIME = -- [ FindBoost.cmake:559 ] Boost_ADDITIONAL_VERSIONS = -- [ FindBoost.cmake:561 ] Boost_NO_SYSTEM_PATHS = -- [ FindBoost.cmake:613 ] Declared as CMake or Environmental Variables: -- [ FindBoost.cmake:615 ] BOOST_ROOT = -- [ FindBoost.cmake:617 ] BOOST_INCLUDEDIR = /home/user/thirdparty/boost_1_59_0 -- [ FindBoost.cmake:619 ] BOOST_LIBRARYDIR = -- [ FindBoost.cmake:621 ] _boost_TEST_VERSIONS = 1.59.0;1.59 -- [ FindBoost.cmake:690 ] Include debugging info: -- [ FindBoost.cmake:692 ] _boost_INCLUDE_SEARCH_DIRS = /home/user/thirdparty/boost_1_59_0;PATHS;C:/boost/include;C:/boost;/sw/local/include -- [ FindBoost.cmake:694 ] _boost_PATH_SUFFIXES = boost-1_59_0;boost_1_59_0;boost/boost-1_59_0;boost/boost_1_59_0;boost-1_59;boost_1_59;boost/boost-1_59;boost/boost_1_59 So I see that the FindBoost module picked up my BOOST_INCLUDEDIR hint. I looked at the source for the FindBoost module, and it comes down to: find_path(NAMES boost/config.hpp ...). The file exists exactly where CMake says it's looking. $ ls -l /home/user/thirdparty/boost_1_59_0/boost/config.hpp -r--r--r-- 1 user user 2188 Nov 30 16:20 /home/user/thirdparty/boost_1_59_0/boost/config.hpp Yet CMake is still setting Boost_INCLUDE_DIR-NOTFOUND. I have tried removing boost_1_59_0 from my BOOST_INCLUDEDIR hint (since I saw that portion of the path in the suffixes, but it doesn't help). The only way I am able to get CMake to locate the boost headers is to install them into a global location like /usr/local/include (which I'd like to avoid).
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake