I begin by saying that this is not an issue with environment variables.
When I use the header-only libraries, everything works fine with this:
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost REQUIRED)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
add_executable(TestCMake Program.cpp)
target_link_libraries(TestCMake ${Boost_LIBRARIES})
endif()
But when I try to require a library by changing find_package(Boost REQUIRED)
to find_package(Boost REQUIRED COMPONENTS system)
I get an error:
Unable to find the requested Boost libraries.
Boost version: 1.67.0
Boost include path: D:/boost/boost_1_67_0
Could not find the following Boost libraries:
boost_system
No Boost libraries were found. You may need to set BOOST_LIBRARYDIR to the
directory containing Boost libraries or BOOST_ROOT to the location of
Boost.
This answer on another question suggests that CMake expects the Boost binaries to be named in a certain way:
boost_thread-vc100-mt-1_51
boost_thread-vc100-mt
boost_thread-mt-1_51
boost_thread-mt
boost_thread
I have a precompiled binary (acquired from here) named boost_system-vc141-mt-x32-1_67.lib
. How could I make CMake recognize the naming convention used in my binaries?
Comments for this downvoted answer on that other question suggest against renaming the files.