Find_package () does not detect promotion on Windows Cmake

I am using a windows system. I want to use the Boost library using CMake. I installed boost on C: \ boost_1_55_0 \ Here is my CMakeLists.txt file

set(Boost_USE_STATIC_LIBS ON) set(Boost_USE_MULTITHREADED ON) set(Boost_USE_STATIC_RUNTIME OFF) find_package(Boost 1.55.0 COMPONENTS thread) if(Boost_FOUND) include_directories(${Boost_INCLUDE_DIRS}) LINK_DIRECTORIES(${Boost_LIBRARY_DIRS}) add_executable (linking_with_boost main.cc sqr.cc) target_link_libraries(linking_with_boost ${Boost_LIBRARIES}) else() message(STATUS "Fail asdasd!") endif() 

I get - Can't find Boost Output:

 $ cmake ../ -- Could NOT find Boost -- Fail asdasd! -- Configuring done -- Generating done -- Build files have been written to: D:/ubuntu_share/programming/C++/practice/cm ake/linking_with_boost/build_win 
+8
boost visual-studio-2010 cmake
source share
4 answers

On Windows 7 x64, I have Boost 1.58 installed for C: \ SDKs \ boost_1_58_0. In order for cMake to find all the relevant files, I had to add the following three system variables:

     BOOST_INCLUDEDIR C: \ SDKs \ boost_1_58_0 \
     BOOST_LIBRARYDIR C: \ SDKs \ boost_1_58_0 \ lib64-msvc-12.0
     BOOST_ROOT C: \ SDKs \ boost_1_58_0 \ boost
+7
source share

In addition to BOOST_ROOT, I also needed to set the variable BOOST_LIBRARYDIR. In my case, it was c: \ Program Files \ boost_1_56_0 \ lib64-msvc-12.0

+11
source share

Before running cmake you must set the BOOST_ROOT environment BOOST_ROOT c:\boost_1_55_0 . Also see cmake --help-module FindBoost for more help.

+8
source share

I spent many hours on this problem and finally resolved it using several variables described in the FindBoost manual here https://cmake.org/cmake/help/v3.0/module/FindBoost.html

The following variables helped me:

 set (Boost_DETAILED_FAILURE_MSG ON) set (Boost_THREADAPI win32) set (BOOST_ROOT "/boost_1_40_0") set (Boost_LIBRARY_DIR /boost_1_40_0/lib") set (Boost_COMPILER "-vc") set (Boost_USE_STATIC_RUNTIME ON) set (BOOST_DEBUG ON) #<---------- Real life saver 
+1
source share

All Articles