Cmake doesn't find Boost
Are you sure you are doing it the correct way? The idea is that CMake sets BOOST_INCLUDE_DIR
, BOOST_LIBRARYDIR
and BOOST_ROOT
automatically. Do something like this in CMakeLists.txt
:
FIND_PACKAGE(Boost)
IF (Boost_FOUND)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
ADD_DEFINITIONS( "-DHAS_BOOST" )
ENDIF()
If boost is not installed in a default location and can, thus, not be found by CMake, you can tell CMake where to look for boost like this:
SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "C:/win32libs/boost")
SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "C:/win32libs/boost/lib")
Of course, those two lines have to be before the FIND_PACKAGE(Boost)
in CMakeLists.txt
.
Cmake error: Could NOT find Boost (missing: Boost_INCLUDE_DIR)
I solved this by adding sentence set(BOOST_ROOT C:/local/boost_1_71_0)
before find_package(Boost REQUIRED)
LOL...
But I still wonder why I need to add this.
CMake does not find Boost on Custom Location on Windows
I have found a solution.
As mentioned in the last edit I made to my question, the first issue with the compiler could be fixed with the -DBoost_COMPILER=-vc142
option.
The second could be solved by using the -DBoost_USE_STATIC_LIBS=ON
.
So the set
block in the CMakeLists
for boost is now:
set(BOOST_ROOT "boost_1_73_0")
set(Boost_COMPILER "-vc142")
set(Boost_USE_STATIC_LIBS ON)
With these variables set, CMake runs without any problems.
Related Topics
Does Std::Stack Expose Iterators
Are "Seekp" & "Seekg" Interchangeable
C++ - Repeatedly Using Istringstream
Howto Create Combinations of Several Vectors Without Hardcoding Loops in C++
How to Make Std::Make_Unique a Friend of My Class
How to Set a Breakpoint in Gdb That Is Conditional on the Call Stack
How to Reduce the Size of Executable Produced by Mingw G++ Compiler
Will Exit() or an Exception Prevent an End-Of-Scope Destructor from Being Called
C++ String Literal Data Type Storage
Is It Unspecified Behavior to Compare Pointers to Different Arrays for Equality
Can Std::Launder Be Used to Convert an Object Pointer to Its Enclosing Array Pointer
Msvc 2015 Universal Crt for App-Local Deployment
How to Reliably Get Size of C-Style Array
How to Set Breakpoint at the Very Beginning of Program Execution