I started a fresh c++ project trying to use boost program_options. Unfortunately I have trouble with cmake; depending on what I try I either get a gmake error not beeing able to build a file or another one about target patterns not containing %
.
Actual errors are:
While using ${Boost_LIBRARIES} (case 1): gmake error: No rule to build /usr/local/lib/libbooost_program_options.so
While using Boost::program_options (case 2): gmake error: Target pattern does not conaint "%". Stop.
I sourced my solution attempts from this SO thread: How to link C++ program with Boost using CMake
About case 1: this provides a step by step guide for this problem. Unfortunately after step one "check if the file exists" there is no hint at what to do if it DOES exists, which it does in my case.
stat /usr/local/lib/libboost_program_options.so
Datei: /usr/local/lib/libboost_program_options.so -> libboost_program_options.so.1.62.0
Other threads, such as "No rule to make target" error in cmake when linking to shared library suggest using finder scripts, which I already do.
edit: Thanks to a comment it turned out i was blind for parts of the error message: The path plugged into the makefile is "Boost::program_options-NOTFOUND" which will obviously result in an error.
About case 2: Target pattern contains no '%'. Makefile implies that it is a path problem with any of my paths. I have zero idea how to further debug the problem, as debugging cmake scripts seems to be not well supported. Info on this is hard to find on any search engine.
The two versions of cmake scripts I used look like this:
cmake_minimum_required(VERSION 3.13)
project(probsim)
set(CMAKE_CXX_STANDARD 17)
FIND_PACKAGE(Boost COMPONENTS program_options REQUIRED )
add_executable(probsim main.cpp)
target_link_libraries(probsim ${Boost_LIBRARIES})
# alternative: target_link_libraries(probsim Boost::program_options)
Results are:
-- Boost version: 1.62.0
-- Found the following Boost libraries:
-- program_options
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ketzu/CLionProjects/probsim/cmake-build-debug
Summary: Cmake creates an invalid makefile one way or another, the reason seems to be related to paths used on my filesystem.