Reputation: 186
I am attempting to build PCL from source, but CMake cannot locate some of the libraries. However when I check the libraries are there. I know this has been asked plenty already but I am just starting out with CMake I've been searching the internet for days and can't find a solution that works. I feel like I'm missing something any help would be appreciated
So I wrote this in my CMakeLists.txt as others have suggested
cmake_minimum_required(VERSION 3.13)
set(Boost_ADDITIONAL_VERSIONS "1.67.0")
set(BOOST_ROOT "C:/local/boost_1_67_0/boost")
set(BOOST_INCLUDEDIR "C:/local/boost_1_67_0/")
set(BOOST_LIBRARYDIR "C:/local/boost_1_67_0/lib64-msvc-14.0")
set (Boost_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost 1.67.0)
but I still keep getting the same error:
CMake Error at C:/Program Files/CMake/share/cmake-3.13/Modules/FindBoost.cmake:2100 (message):
Unable to find the requested Boost libraries.
Boost version: 1.67.0
Boost include path: C:/local/boost_1_67_0
Could not find the following static Boost libraries:
boost_filesystem
boost_thread
boost_date_time
boost_iostreams
boost_system
Some (but not all) of the required Boost libraries were found. You may
need to install these additional Boost libraries. Alternatively, set
BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT
to the location of Boost.
Call Stack (most recent call first):
cmake/pcl_find_boost.cmake:36 (find_package)
CMakeLists.txt:428 (include)
Honestly I'll take any suggestions of things I can try at this point. And feel free to comment or message if I can provide any other useful information that I am not thinking of. Thanks
Upvotes: 2
Views: 11326
Reputation: 41840
Like timko.mate suggested, find_package
with components is the right way to do.
However, you should consider using the target based API:
target_link_libraries(your_exe PUBLIC Boost::system Boost::filesystem)
Also, to make CMake finds Boost, you should adjust your prefix path. This is usually done when invoking cmake in your project:
cmake -DMAKE_PREFIX_PATH=c:/local/ ..
That way, no hardcoded path should be in your cmake files.
Upvotes: 1
Reputation: 374
I had the same issue couple of months before. This solved my problem.
find_package(Boost 1.67.0 COMPONENTS system filesystem REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
Upvotes: 0