I am trying to set up a basic Boost.Logging demo project, with Conan and CMake.
I'm using Conan 1.53.0 and CMake 3.22.1, with gcc-11.3.0, on Ubuntu 22.04.1.
First, I use Conan to bring in Boost 1.81, thus my conanfile.txt:
[requires]
boost/1.81.0
[options]
boost:shared=False
[generators]
CMakeDeps
CMakeToolchain
I am using the Conan "toolchain" developer flow, as recommended by the docs. That is why I'm using CMakeToolchain, and that requires CMakeDeps.
For my CMakeLists.txt I have the following:
cmake_minimum_required(VERSION 3.22)
project(log_demo)
set(CMAKE_CXX_STANDARD 17)
set(Boost_USE_STATIC_LIBS ON)
find_package(Boost 1.81.0 COMPONENTS log_setup log REQUIRED)
add_executable(log_demo log_demo.cpp)
target_link_libraries(log_demo PRIVATE Boost::log_setup Boost::log)
Note that I have selected static libs, which matches with the [options] / boost:shared=False selection in conanfile.txt.
Finally, my actual code, log_demo.cpp, is trivial:
#include <boost/log/core.hpp>
#include <boost/log/trivial.hpp>
#include <boost/log/expressions.hpp>
int main()
{
BOOST_LOG_TRIVIAL(debug) << "This is debug";
return 0;
}
I invoke Conan to get Boost with:
$ mkdir build && cd build
$ conan install ..
Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++11
compiler.version=11
os=Linux
os_build=Linux
[options]
[build_requires]
[env]
conanfile.txt: Installing package
Requirements
boost/1.81.0 from 'conancenter' - Cache
bzip2/1.0.8 from 'conancenter' - Cache
libbacktrace/cci.20210118 from 'conancenter' - Cache
zlib/1.2.13 from 'conancenter' - Cache
Packages
boost/1.81.0:dc8aedd23a0f0a773a5fcdcfe1ae3e89c4205978 - Cache
bzip2/1.0.8:c32092bf4d4bb47cf962af898e02823f499b017e - Cache
libbacktrace/cci.20210118:dfbe50feef7f3c6223a476cd5aeadb687084a646 - Cache
zlib/1.2.13:dfbe50feef7f3c6223a476cd5aeadb687084a646 - Cache
...
This generated, amongst other files, conan_toolchain.cmake in this build directory.
Now I can invoke CMake to configure the build:
$ cmake -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Debug ..
-- Using Conan toolchain: /home/david/cpp/log_demo/build/conan_toolchain.cmake
-- The C compiler identification is GNU 11.3.0
-- The CXX compiler identification is GNU 11.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Conan: Component target declared 'Boost::diagnostic_definitions'
-- Conan: Component target declared 'Boost::disable_autolinking'
-- Conan: Component target declared 'Boost::dynamic_linking'
-- Conan: Component target declared 'Boost::headers'
-- Conan: Component target declared 'Boost::boost'
-- Conan: Component target declared 'boost::_libboost'
-- Conan: Component target declared 'Boost::atomic'
-- Conan: Component target declared 'Boost::container'
-- Conan: Component target declared 'Boost::context'
-- Conan: Component target declared 'Boost::date_time'
-- Conan: Component target declared 'Boost::exception'
-- Conan: Component target declared 'Boost::math'
-- Conan: Component target declared 'Boost::math_c99'
-- Conan: Component target declared 'Boost::math_c99f'
-- Conan: Component target declared 'Boost::math_c99l'
-- Conan: Component target declared 'Boost::math_tr1'
-- Conan: Component target declared 'Boost::math_tr1f'
-- Conan: Component target declared 'Boost::math_tr1l'
-- Conan: Component target declared 'Boost::program_options'
-- Conan: Component target declared 'Boost::regex'
-- Conan: Component target declared 'Boost::serialization'
-- Conan: Component target declared 'Boost::stacktrace'
-- Conan: Component target declared 'Boost::stacktrace_addr2line'
-- Conan: Component target declared 'Boost::stacktrace_backtrace'
-- Conan: Component target declared 'Boost::stacktrace_basic'
-- Conan: Component target declared 'Boost::stacktrace_noop'
-- Conan: Component target declared 'Boost::system'
-- Conan: Component target declared 'Boost::test'
-- Conan: Component target declared 'Boost::test_exec_monitor'
-- Conan: Component target declared 'Boost::url'
-- Conan: Component target declared 'Boost::wserialization'
-- Conan: Component target declared 'Boost::chrono'
-- Conan: Component target declared 'Boost::coroutine'
-- Conan: Component target declared 'Boost::filesystem'
-- Conan: Component target declared 'Boost::json'
-- Conan: Component target declared 'Boost::nowide'
-- Conan: Component target declared 'Boost::prg_exec_monitor'
-- Conan: Component target declared 'Boost::random'
-- Conan: Component target declared 'Boost::thread'
-- Conan: Component target declared 'Boost::timer'
-- Conan: Component target declared 'Boost::type_erasure'
-- Conan: Component target declared 'Boost::unit_test_framework'
-- Conan: Component target declared 'Boost::wave'
-- Conan: Component target declared 'Boost::contract'
-- Conan: Component target declared 'Boost::fiber'
-- Conan: Component target declared 'Boost::fiber_numa'
-- Conan: Component target declared 'Boost::graph'
-- Conan: Component target declared 'Boost::iostreams'
-- Conan: Component target declared 'Boost::locale'
-- Conan: Component target declared 'Boost::log'
-- Conan: Component target declared 'Boost::log_setup'
-- Conan: Target declared 'boost::boost'
-- Conan: Target declared 'BZip2::BZip2'
-- Conan: Including build module from '/home/david/.conan/data/bzip2/1.0.8/_/_/package/c32092bf4d4bb47cf962af898e02823f499b017e/lib/cmake/conan-official-bzip2-variables.cmake'
-- Conan: Target declared 'ZLIB::ZLIB'
-- Conan: Target declared 'libbacktrace::libbacktrace'
-- Configuring done
-- Generating done
-- Build files have been written to: /home/david/cpp/log_demo/build
And where things go wrong is with linking against Boost.Log:
$ cmake --build .
[ 50%] Building CXX object CMakeFiles/log_demo.dir/log_demo.cpp.o
[100%] Linking CXX executable log_demo
/usr/bin/ld: CMakeFiles/log_demo.dir/log_demo.cpp.o: in function `main':
/home/david/cpp/log_demo/log_demo.cpp:7: undefined reference to `boost::log::v2s_mt_posix::trivial::logger::get()'
/usr/bin/ld: /home/david/cpp/log_demo/log_demo.cpp:7: undefined reference to `boost::log::v2s_mt_posix::trivial::logger::get()'
/usr/bin/ld: CMakeFiles/log_demo.dir/log_demo.cpp.o: in function `boost::log::v2s_mt_posix::record::reset()':
/usr/include/boost/log/core/record.hpp:157: undefined reference to `boost::log::v2s_mt_posix::record_view::public_data::destroy(boost::log::v2s_mt_posix::record_view::public_data const*)'
/usr/bin/ld: CMakeFiles/log_demo.dir/log_demo.cpp.o: in function `boost::log::v2s_mt_posix::record boost::log::v2s_mt_posix::sources::basic_composite_logger<char, boost::log::v2s_mt_posix::sources::severity_logger_mt<boost::log::v2s_mt_posix::trivial::severity_level>, boost::log::v2s_mt_posix::sources::multi_thread_model<boost::log::v2s_mt_posix::aux::light_rw_mutex>, boost::log::v2s_mt_posix::sources::features<boost::log::v2s_mt_posix::sources::severity<boost::log::v2s_mt_posix::trivial::severity_level> > >::open_record<boost::parameter::aux::tagged_argument_list_of_1<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::severity, boost::log::v2s_mt_posix::trivial::severity_level const> > >(boost::parameter::aux::tagged_argument_list_of_1<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::severity, boost::log::v2s_mt_posix::trivial::severity_level const> > const&)':
/usr/include/boost/log/sources/basic_logger.hpp:463: undefined reference to `boost::log::v2s_mt_posix::core::get_logging_enabled() const'
/usr/bin/ld: CMakeFiles/log_demo.dir/log_demo.cpp.o: in function `boost::log::v2s_mt_posix::aux::record_pump<boost::log::v2s_mt_posix::sources::severity_logger_mt<boost::log::v2s_mt_posix::trivial::severity_level> >::record_pump(boost::log::v2s_mt_posix::sources::severity_logger_mt<boost::log::v2s_mt_posix::trivial::severity_level>&, boost::log::v2s_mt_posix::record&)':
/usr/include/boost/log/sources/record_ostream.hpp:508: undefined reference to `boost::log::v2s_mt_posix::aux::stream_provider<char>::allocate_compound(boost::log::v2s_mt_posix::record&)'
/usr/bin/ld: CMakeFiles/log_demo.dir/log_demo.cpp.o: in function `boost::log::v2s_mt_posix::aux::record_pump<boost::log::v2s_mt_posix::sources::severity_logger_mt<boost::log::v2s_mt_posix::trivial::severity_level> >::auto_release::~auto_release()':
/usr/include/boost/log/sources/record_ostream.hpp:493: undefined reference to `boost::log::v2s_mt_posix::aux::stream_provider<char>::release_compound(boost::log::v2s_mt_posix::aux::stream_provider<char>::stream_compound*)'
/usr/bin/ld: CMakeFiles/log_demo.dir/log_demo.cpp.o: in function `boost::log::v2s_mt_posix::sources::aux::severity_level<boost::log::v2s_mt_posix::trivial::severity_level>::set_value(boost::log::v2s_mt_posix::trivial::severity_level)':
/usr/include/boost/log/sources/severity_feature.hpp:137: undefined reference to `boost::log::v2s_mt_posix::sources::aux::get_severity_level()'
/usr/bin/ld: CMakeFiles/log_demo.dir/log_demo.cpp.o: in function `boost::log::v2s_mt_posix::record boost::log::v2s_mt_posix::sources::basic_logger<char, boost::log::v2s_mt_posix::sources::severity_logger_mt<boost::log::v2s_mt_posix::trivial::severity_level>, boost::log::v2s_mt_posix::sources::multi_thread_model<boost::log::v2s_mt_posix::aux::light_rw_mutex> >::open_record_unlocked<boost::parameter::aux::tagged_argument_list_of_1<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::severity, boost::log::v2s_mt_posix::trivial::severity_level const> > >(boost::parameter::aux::tagged_argument_list_of_1<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::severity, boost::log::v2s_mt_posix::trivial::severity_level const> > const&)':
/usr/include/boost/log/sources/basic_logger.hpp:263: undefined reference to `boost::log::v2s_mt_posix::core::open_record(boost::log::v2s_mt_posix::attribute_set const&)'
/usr/bin/ld: CMakeFiles/log_demo.dir/log_demo.cpp.o: in function `boost::log::v2s_mt_posix::core::push_record(boost::log::v2s_mt_posix::record&&)':
/usr/include/boost/log/core/core.hpp:308: undefined reference to `boost::log::v2s_mt_posix::core::push_record_move(boost::log::v2s_mt_posix::record&)'
collect2: error: ld returned 1 exit status
gmake[2]: *** [CMakeFiles/log_demo.dir/build.make:97: log_demo] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/log_demo.dir/all] Error 2
gmake: *** [Makefile:91: all] Error 2
This linker error - undefined reference to 'boost::log::v2s_mt_posix::trivial::logger::get()' - occurs for a lot of people, it seems. There are many suggested workarounds and hacks, but none of my attempts to find one that works have been successful. Apparently this error relates to an attempt to link against the static libraries of Boost, which is actually what I want.
I tried the -v option for CMake, to see what the linker command is:
$ cmake --build . -v
...
[ 50%] Linking CXX executable log_demo
/usr/bin/cmake -E cmake_link_script CMakeFiles/log_demo.dir/link.txt --verbose=1
/usr/bin/c++ -m64 -g -m64 CMakeFiles/log_demo.dir/log_demo.cpp.o -o log_demo
...
I see no mention of any Boost libraries on that c++ command line - that seems wrong to me. Why isn't there a -lboost_log and -lboost_log_setup present?
This must be the fourth time in ten years I've tried to set up Boost.Log, each time it's different (due to Conan changes, or CMake changes), so I'm hoping I'm missing something really obvious here...
Your question is well detailed in terms of steps and logs, thank you for providing such good information.
Your error comes from a configuration mismatch. Your Conan profile shows build_type=Release, but your CMake command uses Debug, you need to use the very same configuration for both. So, if you want to update it on Conan command, you need to pass conan install .. -s build_type=Debug.
Here I'm using Release, but the idea is the same, using your files we will have:
$ conan install .. && cmake -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release .. && cmake --build .
Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++11
compiler.version=11
os=Linux
os_build=Linux
[options]
[build_requires]
[env]
conanfile.txt: Installing package
Requirements
boost/1.81.0 from 'conancenter' - Cache
bzip2/1.0.8 from 'conancenter' - Cache
libbacktrace/cci.20210118 from 'conancenter' - Cache
zlib/1.2.13 from 'conancenter' - Cache
Packages
boost/1.81.0:dc8aedd23a0f0a773a5fcdcfe1ae3e89c4205978 - Cache
bzip2/1.0.8:c32092bf4d4bb47cf962af898e02823f499b017e - Cache
libbacktrace/cci.20210118:dfbe50feef7f3c6223a476cd5aeadb687084a646 - Cache
zlib/1.2.13:dfbe50feef7f3c6223a476cd5aeadb687084a646 - Cache
Installing (downloading, building) binaries...
bzip2/1.0.8: Already installed!
libbacktrace/cci.20210118: Already installed!
zlib/1.2.13: Already installed!
boost/1.81.0: Already installed!
conanfile.txt: Generator txt created conanbuildinfo.txt
conanfile.txt: WARN: Using the new toolchains and generators without specifying a build profile (e.g: -pr:b=default) is discouraged and might cause failures and unexpected behavior
conanfile.txt: Generator 'CMakeDeps' calling 'generate()'
conanfile.txt: WARN: Using the new toolchains and generators without specifying a build profile (e.g: -pr:b=default) is discouraged and might cause failures and unexpected behavior
conanfile.txt: Generator 'CMakeToolchain' calling 'generate()'
conanfile.txt: Preset 'release' added to CMakePresets.json. Invoke it manually using 'cmake --preset release'
conanfile.txt: If your CMake version is not compatible with CMakePresets (<3.19) call cmake like: 'cmake <path> -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=/home/conan/project/build_linux/conan_toolchain.cmake -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=Release'
conanfile.txt: Aggregating env generators
conanfile.txt: Generated conaninfo.txt
conanfile.txt: Generated graphinfo
-- Using Conan toolchain: /home/conan/project/build_linux/conan_toolchain.cmake
-- The CXX compiler identification is GNU 11.1.0
-- Check for working CXX compiler: /usr/local/bin/c++
-- Check for working CXX compiler: /usr/local/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Conan: Component target declared 'Boost::diagnostic_definitions'
-- Conan: Component target declared 'Boost::disable_autolinking'
-- Conan: Component target declared 'Boost::dynamic_linking'
-- Conan: Component target declared 'Boost::headers'
-- Conan: Component target declared 'Boost::boost'
-- Conan: Component target declared 'boost::_libboost'
-- Conan: Component target declared 'Boost::atomic'
-- Conan: Component target declared 'Boost::container'
-- Conan: Component target declared 'Boost::context'
-- Conan: Component target declared 'Boost::date_time'
-- Conan: Component target declared 'Boost::exception'
-- Conan: Component target declared 'Boost::math'
-- Conan: Component target declared 'Boost::math_c99'
-- Conan: Component target declared 'Boost::math_c99f'
-- Conan: Component target declared 'Boost::math_c99l'
-- Conan: Component target declared 'Boost::math_tr1'
-- Conan: Component target declared 'Boost::math_tr1f'
-- Conan: Component target declared 'Boost::math_tr1l'
-- Conan: Component target declared 'Boost::program_options'
-- Conan: Component target declared 'Boost::regex'
-- Conan: Component target declared 'Boost::serialization'
-- Conan: Component target declared 'Boost::stacktrace'
-- Conan: Component target declared 'Boost::stacktrace_addr2line'
-- Conan: Component target declared 'Boost::stacktrace_backtrace'
-- Conan: Component target declared 'Boost::stacktrace_basic'
-- Conan: Component target declared 'Boost::stacktrace_noop'
-- Conan: Component target declared 'Boost::system'
-- Conan: Component target declared 'Boost::test'
-- Conan: Component target declared 'Boost::test_exec_monitor'
-- Conan: Component target declared 'Boost::url'
-- Conan: Component target declared 'Boost::wserialization'
-- Conan: Component target declared 'Boost::chrono'
-- Conan: Component target declared 'Boost::coroutine'
-- Conan: Component target declared 'Boost::filesystem'
-- Conan: Component target declared 'Boost::json'
-- Conan: Component target declared 'Boost::nowide'
-- Conan: Component target declared 'Boost::prg_exec_monitor'
-- Conan: Component target declared 'Boost::random'
-- Conan: Component target declared 'Boost::thread'
-- Conan: Component target declared 'Boost::timer'
-- Conan: Component target declared 'Boost::type_erasure'
-- Conan: Component target declared 'Boost::unit_test_framework'
-- Conan: Component target declared 'Boost::wave'
-- Conan: Component target declared 'Boost::contract'
-- Conan: Component target declared 'Boost::fiber'
-- Conan: Component target declared 'Boost::fiber_numa'
-- Conan: Component target declared 'Boost::graph'
-- Conan: Component target declared 'Boost::iostreams'
-- Conan: Component target declared 'Boost::locale'
-- Conan: Component target declared 'Boost::log'
-- Conan: Component target declared 'Boost::log_setup'
-- Conan: Target declared 'boost::boost'
-- Conan: Target declared 'BZip2::BZip2'
-- Conan: Including build module from '/home/conan/.conan/data/bzip2/1.0.8/_/_/package/c32092bf4d4bb47cf962af898e02823f499b017e/lib/cmake/conan-official-bzip2-variables.cmake'
-- Conan: Target declared 'ZLIB::ZLIB'
-- Conan: Target declared 'libbacktrace::libbacktrace'
-- Configuring done
-- Generating done
-- Build files have been written to: /home/conan/project/build_linux
Scanning dependencies of target log_demo
[ 50%] Building CXX object CMakeFiles/log_demo.dir/log_demo.cpp.o
[100%] Linking CXX executable log_demo
[100%] Built target log_demo
$ ./log_demo
[2023-01-31 08:42:44.851824] [0x0000004001b498c0] [debug] This is debug
Note those package IDs used by me are the same from your log, which means, we are using the very same configuration of packages.
As uilianries explained, you are using default profile file which sets build type to Release. To easily change its build type you can use following command:
$ conan profile update settings.build_type=Debug default
Related
I am tryting to setup a build of a project on my Macbook which should use GCC with both Conan & CMake.
I have set the following environment variables:
export CC=/usr/local/bin/gcc-12
export CXX=/usr/local/bin/g++-12
When I run Conan all libraries are installed (and built if missing):
conan install ../ --build=missing
My .conan/profiles/default shows that Conan has used gcc-12.
[settings]
os=Macos
os_build=Macos
arch=armv8
arch_build=armv8
compiler=gcc
compiler.version=12
compiler.libcxx=libstdc++11
build_type=Release
[options]
[build_requires]
[env]
When I run CMake with:
cmake -DCMAKE_C_COMPILER=/usr/local/bin/gcc-12 -DCMAKE_CXX_COMPILER=/usr/local/bin/g++-12 ../
I get the following error
cmake ../
-- Ubuntu: Using Conan to manage dependencies
-- Conan: Adjusting output directories
-- Conan: Using cmake global configuration
-- Conan: Adjusting default RPATHs Conan policies
-- Conan: Adjusting language standard
-- Current conanbuildinfo.cmake directory:
~/some-dir/build
CMake Error at build/conanbuildinfo.cmake:1812 (message):
Incorrect 'apple-clang', is not the one detected by CMake: 'GNU'
Call Stack (most recent call first):
build/conanbuildinfo.cmake:1369 (conan_check_compiler)
CMakeLists.txt:62 (conan_basic_setup)
build/conanbuildinfo.cmake:1369 contains the following:
message(FATAL_ERROR "Incorrect '${CONAN_COMPILER}', is not the one
detected by CMake: '${CMAKE_CXX_COMPILER_ID}'")
This indicates that CMake has detected the Conan compiler as AppleClang NOT GCC
I cannot see where conanbuildinfo.cmake gets the value for CONAN_COMPILER from.
How can I force CMake & Conan to use GCC-12?
Problem Background
I am trying to incorporate UnitTest++ into my linux-based C++17 project template. I have done this on windows pretty easily, but I am running into major issues on linux for some reason.
I used Cmake 3.21 on Windows and I am currently using CMake 3.17.5 on Linux.
I downloaded the UnitTest++ source code from the UnitTest++ Github. and proceeded to throw the tar.gz into my 3rdParty folder in my ProjectTemplate. I have had major trouble getting it to build. So I have stripped out everything except for the one 3rd party library I added and the things that folder affects. So at this point all the main() functions are very simple. I am just expecting to see executables that do nothing.
Problem Points
The main executable gets made, but the unit testing executable
(testExecutable) does not get made.
The build fully finishes with no errors even though an executable
failed to be made.
The UnitTest++ 3rd party library fails to untar with no errors
output.
I have included the build output.
Why is the testExecutable not getting made? More importantly, why is my UnitTest++ failing to untar?
Directory Structure
ProjectTemplate
+3rdParty
-CMakeLists.txt (3rd party cmake)
-unittest-cpp-2.0.0.tar.gz
+build
+src
-ClassTemplate.cpp (just a plain class file - compiles fine)
-ClassTemplate.hpp (just a plain class file - compiles fine)
-main.cpp (basic int main function)
+UnitTests
-CMakeLists.txt (unit test cmake)
-UnittestcppMain.cpp (basic int main function)
-CMakeLists.txt (root cmake)
Build Output
Output from cmake generation / configure
[main] Configuring folder: ProjectTemplate
[proc] Executing command: /usr/bin/cmake3 --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_C_COMPILER:FILEPATH=/opt/rh/devtoolset-8/root/usr/bin/gcc -DCMAKE_CXX_COMPILER:FILEPATH=/opt/rh/devtoolset-8/root/usr/bin/g++ -S/path/to/ProjectTemplate -B/path/to/ProjectTemplate/build -G "Unix Makefiles"
[cmake] Not searching for unused variables given on the command line.
[cmake] -- The CXX compiler identification is GNU 8.3.1
[cmake] -- Check for working CXX compiler: /opt/rh/devtoolset-8/root/usr/bin/g++
[cmake] -- Check for working CXX compiler: /opt/rh/devtoolset-8/root/usr/bin/g++ - works
[cmake] -- Detecting CXX compiler ABI info
[cmake] -- Detecting CXX compiler ABI info - done
[cmake] -- Detecting CXX compile features
[cmake] -- Detecting CXX compile features - done
[cmake] Made it to this
[cmake] -- Configuring done
[cmake] -- Generating done
[cmake] -- Build files have been written to: /path/to/ProjectTemplate/build
output from build
[main] Building folder: ProjectTemplate
[build] Starting build
[proc] Executing command: /usr/bin/cmake3 --build /path/to/ProjectTemplate/build --config Debug --target ExecutableName -j 18 --
[build] Scanning dependencies of target ExecutableLib
[build] [ 25%] Building CXX object CMakeFiles/ExecutableLib.dir/src/ClassTemplate.cpp.o
[build] [ 50%] Linking CXX static library libExecutableLib.a
[build] [ 50%] Built target ExecutableLib
[build] Scanning dependencies of target ExecutableName
[build] [ 75%] Building CXX object CMakeFiles/ExecutableName.dir/src/main.cpp.o
[build] [100%] Linking CXX executable ExecutableName
[build] [100%] Built target ExecutableName
[build] Build finished with exit code 0
UPDATE
Thanks to 273K a solution was pointed out. I had accidentally switched my target from "All" to "ExecutableName" in VSCode. I have included a screenshot of the problem area and what it had to be set to in order to avoid this problem for future users who might be using VSCode and stumble on this question.
This is the bottom edge of VSCode, this is where the CMake extension puts it build options.
Somehow you set --target ExecutableName, that limits the build to a single target, the main executable ExecutableName. Try to select another target, or let it unset.
I tried to build rtabmap_ros in my catkin_ws and I got this error:
user#user-desktop:~/catkin_ws$ catkin_make
Base path: /home/user/catkin_ws
Source space: /home/user/catkin_ws/src
Build space: /home/user/catkin_ws/build
Devel space: /home/user/catkin_ws/devel
Install space: /home/user/catkin_ws/install
####
#### Running command: "cmake /home/user/catkin_ws/src -DCATKIN_DEVEL_PREFIX=/home/user/catkin_ws/devel -DCMAKE_INSTALL_PREFIX=/home/user/catkin_ws/install -G Unix Makefiles" in "/home/user/catkin_ws/build"
####
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Using CATKIN_DEVEL_PREFIX: /home/user/catkin_ws/devel
-- Using CMAKE_PREFIX_PATH: /home/user/catkin_ws/devel;/opt/ros/melodic
-- This workspace overlays: /home/user/catkin_ws/devel;/opt/ros/melodic
-- Found PythonInterp: /usr/bin/python2 (found suitable version "2.7.17", minimum required is "2")
-- Using PYTHON_EXECUTABLE: /usr/bin/python2
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/user/catkin_ws/build/test_results
-- Found gtest sources under '/usr/src/googletest': gtests will be built
-- Found gmock sources under '/usr/src/googletest': gmock will be built
-- Found PythonInterp: /usr/bin/python2 (found version "2.7.17")
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.7.29
-- BUILD_SHARED_LIBS is on
-- BUILD_SHARED_LIBS is on
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~ traversing 1 packages in topological order:
-- ~~ - rtabmap_ros
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- +++ processing catkin package: 'rtabmap_ros'
-- ==> add_subdirectory(rtabmap_ros)
-- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
CMake Warning at rtabmap_ros/CMakeLists.txt:31 (find_package):
By not providing "Findfiducial_msgs.cmake" in CMAKE_MODULE_PATH this
project has asked CMake to find a package configuration file provided by
"fiducial_msgs", but CMake did not find one.
Could not find a package configuration file provided by "fiducial_msgs"
with any of the following names:
fiducial_msgsConfig.cmake
fiducial_msgs-config.cmake
Add the installation prefix of "fiducial_msgs" to CMAKE_PREFIX_PATH or set
"fiducial_msgs_DIR" to a directory containing one of the above files. If
"fiducial_msgs" provides a separate development package or SDK, be sure it
has been installed.
-- Found RTABMap: /opt/ros/melodic/lib/librtabmap_core.so;/opt/ros/melodic/lib/librtabmap_utilite.so;/opt/ros/melodic/lib/librtabmap_gui.so;/usr/lib/aarch64-linux-gnu/libz.so;/opt/ros/melodic/lib/libg2o_core.so;/opt/ros/melodic/lib/libg2o_types_slam2d.so;/opt/ros/melodic/lib/libg2o_types_slam3d.so;/opt/ros/melodic/lib/libg2o_types_sba.so;/opt/ros/melodic/lib/libg2o_stuff.so;/opt/ros/melodic/lib/libg2o_solver_csparse.so;/opt/ros/melodic/lib/libg2o_csparse_extension.so;/usr/lib/aarch64-linux-gnu/libcxsparse.so;/opt/ros/melodic/lib/libg2o_solver_cholmod.so;/usr/lib/aarch64-linux-gnu/libcholmod.so;/usr/lib/aarch64-linux-gnu/libfreenect.so;/usr/lib/aarch64-linux-gnu/libfreenect_sync.so;/usr/lib/libOpenNI2.so;/usr/lib/aarch64-linux-gnu/libdc1394.so;/opt/ros/melodic/lib/liboctomap.so;/opt/ros/melodic/lib/liboctomath.so (Required is at least version "0.20.18")
-- Checking for module 'eigen3'
-- Found eigen3, version 3.3.4
-- Found eigen: /usr/include/eigen3
-- Checking for module 'libopenni'
-- Found libopenni, version 1.5.4.0
-- Found openni: /usr/lib/libOpenNI.so
-- The imported target "vtkGUISupportQt" references the file
"/usr/lib/aarch64-linux-gnu/libvtkGUISupportQt-6.3.so.6.3.0"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
"/usr/lib/cmake/vtk-6.3/VTKTargets.cmake"
but not all the files it references.
-- The imported target "vtkGUISupportQtOpenGL" references the file
"/usr/lib/aarch64-linux-gnu/libvtkGUISupportQtOpenGL-6.3.so.6.3.0"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
"/usr/lib/cmake/vtk-6.3/VTKTargets.cmake"
but not all the files it references.
-- The imported target "vtkGUISupportQtSQL" references the file
"/usr/lib/aarch64-linux-gnu/libvtkGUISupportQtSQL-6.3.so.6.3.0"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
"/usr/lib/cmake/vtk-6.3/VTKTargets.cmake"
but not all the files it references.
-- The imported target "vtkViewsQt" references the file
"/usr/lib/aarch64-linux-gnu/libvtkViewsQt-6.3.so.6.3.0"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
"/usr/lib/cmake/vtk-6.3/VTKTargets.cmake"
but not all the files it references.
-- The imported target "vtkGUISupportQtWebkit" references the file
"/usr/lib/aarch64-linux-gnu/libvtkGUISupportQtWebkit-6.3.so.6.3.0"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
"/usr/lib/cmake/vtk-6.3/VTKTargets.cmake"
but not all the files it references.
-- The imported target "vtkRenderingQt" references the file
"/usr/lib/aarch64-linux-gnu/libvtkRenderingQt-6.3.so.6.3.0"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
"/usr/lib/cmake/vtk-6.3/VTKTargets.cmake"
but not all the files it references.
-- The imported target "vtkRenderingQtTCL" references the file
"/usr/lib/aarch64-linux-gnu/libvtkRenderingQtTCL-6.3.so.6.3.0"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
"/usr/lib/cmake/vtk-6.3/VTKTargets.cmake"
but not all the files it references.
-- The imported target "vtkRenderingPythonTkWidgets" references the file
"/usr/lib/aarch64-linux-gnu/libvtkRenderingPythonTkWidgets.so"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
"/usr/lib/cmake/vtk-6.3/VTKTargets.cmake"
but not all the files it references.
-- The imported target "vtk" references the file
"/usr/bin/vtk"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
"/usr/lib/cmake/vtk-6.3/VTKTargets.cmake"
but not all the files it references.
-- The imported target "vtkRenderingQtPythonD" references the file
"/usr/lib/aarch64-linux-gnu/libvtkRenderingQtPython27D-6.3.so.6.3.0"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
"/usr/lib/cmake/vtk-6.3/VTKTargets.cmake"
but not all the files it references.
-- Found libusb-1.0: /usr/include
-- Checking for module 'flann'
-- Found flann, version 1.9.1
-- Found Flann: /usr/lib/aarch64-linux-gnu/libflann_cpp_s.a
-- Found qhull: /usr/lib/aarch64-linux-gnu/libqhull.so
-- Found PCL_COMMON: /usr/lib/aarch64-linux-gnu/libpcl_common.so
-- Found PCL_OCTREE: /usr/lib/aarch64-linux-gnu/libpcl_octree.so
-- Found PCL_IO: /usr/lib/aarch64-linux-gnu/libpcl_io.so
-- Found PCL_KDTREE: /usr/lib/aarch64-linux-gnu/libpcl_kdtree.so
-- Found PCL_SEARCH: /usr/lib/aarch64-linux-gnu/libpcl_search.so
-- Found PCL_SURFACE: /usr/lib/aarch64-linux-gnu/libpcl_surface.so
-- Found PCL_FILTERS: /usr/lib/aarch64-linux-gnu/libpcl_filters.so
-- Found PCL_2D: /usr/include/pcl-1.8
-- Found PCL_FEATURES: /usr/lib/aarch64-linux-gnu/libpcl_features.so
-- Found PCL_REGISTRATION: /usr/lib/aarch64-linux-gnu/libpcl_registration.so
-- Found PCL_SAMPLE_CONSENSUS: /usr/lib/aarch64-linux-gnu/libpcl_sample_consensus.so
-- Found PCL_GEOMETRY: /usr/include/pcl-1.8
-- Found PCL_ML: /usr/lib/aarch64-linux-gnu/libpcl_ml.so
-- Found PCL_SEGMENTATION: /usr/lib/aarch64-linux-gnu/libpcl_segmentation.so
-- Found PCL_VISUALIZATION: /usr/lib/aarch64-linux-gnu/libpcl_visualization.so
-- RTABMAP_SYNC_MULTI_RGBD = OFF
-- RTABMAP_SYNC_USER_DATA = OFF
-- rtabmap_ros: 18 messages, 16 services
-- WITH octomap_msgs
-- WITH apriltag_ros
-- WITH find_object_2d
-- checking for module 'OGRE'
-- found OGRE, version 1.9.0
-- WITH rviz
-- WITH costmap_2d
-- Configuring done
-- Generating done
-- Build files have been written to: /home/user/catkin_ws/build
####
#### Running command: "make -j4 -l4" in "/home/user/catkin_ws/build"
####
Scanning dependencies of target rtabmap_costmap_plugins
Scanning dependencies of target _rtabmap_ros_generate_messages_check_deps_Point2f
Scanning dependencies of target rtabmap_point_cloud_assembler
Scanning dependencies of target rtabmap_pointcloud_to_depthimage
make[2]: *** No rule to make target '/usr/lib/aarch64-linux-gnu/libvtkGUISupportQtOpenGL-6.3.so.6.3.0', needed by '/home/user/catkin_ws/devel/lib/rtabmap_ros/point_cloud_assembler'. Stop.
make[2]: *** Waiting for unfinished jobs....
[ 0%] Building CXX object rtabmap_ros/CMakeFiles/rtabmap_point_cloud_assembler.dir/src/PointCloudAssemblerNode.cpp.o
[ 0%] Built target _rtabmap_ros_generate_messages_check_deps_Point2f
make[2]: *** No rule to make target '/usr/lib/aarch64-linux-gnu/libvtkGUISupportQtOpenGL-6.3.so.6.3.0', needed by '/home/user/catkin_ws/devel/lib/rtabmap_ros/pointcloud_to_depthimage'. Stop.
make[2]: *** Waiting for unfinished jobs....
[ 0%] Building CXX object rtabmap_ros/CMakeFiles/rtabmap_pointcloud_to_depthimage.dir/src/PointCloudToDepthImageNode.cpp.o
[ 0%] Building CXX object rtabmap_ros/CMakeFiles/rtabmap_costmap_plugins.dir/src/costmap_2d/static_layer.cpp.o
Scanning dependencies of target _rtabmap_ros_generate_messages_check_deps_NodeData
[ 0%] Built target _rtabmap_ros_generate_messages_check_deps_NodeData
Scanning dependencies of target _rtabmap_ros_generate_messages_check_deps_GetMap
[ 0%] Built target _rtabmap_ros_generate_messages_check_deps_GetMap
Scanning dependencies of target sensor_msgs_generate_messages_cpp
[ 0%] Built target sensor_msgs_generate_messages_cpp
Scanning dependencies of target std_msgs_generate_messages_cpp
[ 0%] Built target std_msgs_generate_messages_cpp
Scanning dependencies of target _rtabmap_ros_generate_messages_check_deps_Info
[ 0%] Built target _rtabmap_ros_generate_messages_check_deps_Info
Scanning dependencies of target _rtabmap_ros_generate_messages_check_deps_GetPlan
[ 0%] Built target _rtabmap_ros_generate_messages_check_deps_GetPlan
Scanning dependencies of target _rtabmap_ros_generate_messages_check_deps_MapGraph
[ 0%] Built target _rtabmap_ros_generate_messages_check_deps_MapGraph
Scanning dependencies of target _rtabmap_ros_generate_messages_check_deps_RemoveLabel
[ 0%] Built target _rtabmap_ros_generate_messages_check_deps_RemoveLabel
Scanning dependencies of target _rtabmap_ros_generate_messages_check_deps_GetNodesInRadius
[ 0%] Built target _rtabmap_ros_generate_messages_check_deps_GetNodesInRadius
Scanning dependencies of target _rtabmap_ros_generate_messages_check_deps_SetLabel
[ 0%] Built target _rtabmap_ros_generate_messages_check_deps_SetLabel
Scanning dependencies of target _rtabmap_ros_generate_messages_check_deps_ScanDescriptor
[ 0%] Built target _rtabmap_ros_generate_messages_check_deps_ScanDescriptor
Scanning dependencies of target _rtabmap_ros_generate_messages_check_deps_MapData
[ 0%] Built target _rtabmap_ros_generate_messages_check_deps_MapData
Scanning dependencies of target _rtabmap_ros_generate_messages_check_deps_Path
[ 0%] Built target _rtabmap_ros_generate_messages_check_deps_Path
Scanning dependencies of target _rtabmap_ros_generate_messages_check_deps_PublishMap
[ 0%] Built target _rtabmap_ros_generate_messages_check_deps_PublishMap
Scanning dependencies of target _rtabmap_ros_generate_messages_check_deps_AddLink
[ 0%] Built target _rtabmap_ros_generate_messages_check_deps_AddLink
Scanning dependencies of target _rtabmap_ros_generate_messages_check_deps_DetectMoreLoopClosures
[ 0%] Built target _rtabmap_ros_generate_messages_check_deps_DetectMoreLoopClosures
Scanning dependencies of target _rtabmap_ros_generate_messages_check_deps_GPS
[ 0%] Built target _rtabmap_ros_generate_messages_check_deps_GPS
Scanning dependencies of target geometry_msgs_generate_messages_cpp
[ 0%] Built target geometry_msgs_generate_messages_cpp
Scanning dependencies of target _rtabmap_ros_generate_messages_check_deps_KeyPoint
[ 0%] Built target _rtabmap_ros_generate_messages_check_deps_KeyPoint
Scanning dependencies of target _rtabmap_ros_generate_messages_check_deps_OdomInfo
[ 0%] Built target _rtabmap_ros_generate_messages_check_deps_OdomInfo
Scanning dependencies of target _rtabmap_ros_generate_messages_check_deps_RGBDImages
CMakeFiles/Makefile2:706: recipe for target 'rtabmap_ros/CMakeFiles/rtabmap_point_cloud_assembler.dir/all' failed
make[1]: *** [rtabmap_ros/CMakeFiles/rtabmap_point_cloud_assembler.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 0%] Built target _rtabmap_ros_generate_messages_check_deps_RGBDImages
CMakeFiles/Makefile2:743: recipe for target 'rtabmap_ros/CMakeFiles/rtabmap_pointcloud_to_depthimage.dir/all' failed
make[1]: *** [rtabmap_ros/CMakeFiles/rtabmap_pointcloud_to_depthimage.dir/all] Error 2
[ 0%] Linking CXX shared library /home/user/catkin_ws/devel/lib/librtabmap_costmap_plugins.so
[ 0%] Built target rtabmap_costmap_plugins
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed
I also have issues installing this particular library libvtkGUISupportQtOpenGL-6.3.so.6.3.0.
It seems that you need to install fiducial_msgs:
sudo apt-get install ros-noetic-fiducial-msgs
In Conan documentation for cmake_find_package generator, it is mentioned that :
In the CMakeList.txt you do not need to specify or include anything related with Conan at all, just rely on the find_package feature
In my case, after calling find_package(boost COMPONENTS boost program_options REQUIRED) in CMakeLists.txt of config module, the ${Boost_INCLUDE_DIRS} variable was empty (undefined) so that CMake failed to build due to boost missing header file <boost/program_options.hpp> included in StartupConfig.cpp.
The only workaround I found is to include(FindBoost.cmake) in the root CMakeLists.txt.
If I comment the include(FindBoost.cmake) and change boost by Boost in the find_package, I get the following build error :
maze/0.1.0: Calling build()
maze/0.1.0: CMake command: cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="/root/.conan/data/maze/0.1.0/_/_/build/5f5fdaf06f8bd18961521dbe87621377ba962aa5/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="/root/.conan/data/maze/0.1.0/_/_/package/5f5fdaf06f8bd18961521dbe87621377ba962aa5" "/root/.conan/data/maze/0.1.0/_/_/build/5f5fdaf06f8bd18961521dbe87621377ba962aa5"
Using Conan toolchain: /root/.conan/data/maze/0.1.0/_/_/build/5f5fdaf06f8bd18961521dbe87621377ba962aa5/conan_toolchain.cmake.
-- The C compiler identification is GNU 9.2.0
-- The CXX compiler identification is GNU 9.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/local/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Conan: Component target declared 'GTest::gtest'
-- Conan: Component target declared 'GTest::gtest_main'
-- Conan: Component target declared 'GTest::gmock'
-- Conan: Component target declared 'GTest::gmock_main'
-- Conan: Target declared 'gtest::gtest'
-- Conan: Component target declared 'boost::headers'
-- Conan: Component target declared 'boost::_boost_cmake'
-- Conan: Component target declared 'boost::diagnostic_definitions'
-- Conan: Component target declared 'boost::disable_autolinking'
-- Conan: Component target declared 'boost::dynamic_linking'
-- Conan: Component target declared 'boost::_libboost'
-- Conan: Component target declared 'boost::atomic'
-- Conan: Component target declared 'boost::container'
-- Conan: Component target declared 'boost::date_time'
-- Conan: Component target declared 'boost::exception'
-- Conan: Component target declared 'boost::math'
-- Conan: Component target declared 'boost::math_c99'
-- Conan: Component target declared 'boost::math_c99f'
-- Conan: Component target declared 'boost::math_c99l'
-- Conan: Component target declared 'boost::math_tr1'
-- Conan: Component target declared 'boost::math_tr1f'
-- Conan: Component target declared 'boost::math_tr1l'
-- Conan: Component target declared 'boost::program_options'
-- Conan: Component target declared 'boost::regex'
-- Conan: Component target declared 'boost::serialization'
-- Conan: Component target declared 'boost::stacktrace'
-- Conan: Component target declared 'boost::stacktrace_addr2line'
-- Conan: Component target declared 'boost::stacktrace_backtrace'
-- Conan: Component target declared 'boost::stacktrace_basic'
-- Conan: Component target declared 'boost::stacktrace_noop'
-- Conan: Component target declared 'boost::system'
-- Conan: Component target declared 'boost::test'
-- Conan: Component target declared 'boost::test_exec_monitor'
-- Conan: Component target declared 'boost::wserialization'
-- Conan: Component target declared 'boost::chrono'
-- Conan: Component target declared 'boost::filesystem'
-- Conan: Component target declared 'boost::nowide'
-- Conan: Component target declared 'boost::prg_exec_monitor'
-- Conan: Component target declared 'boost::random'
-- Conan: Component target declared 'boost::thread'
-- Conan: Component target declared 'boost::timer'
-- Conan: Component target declared 'boost::type_erasure'
-- Conan: Component target declared 'boost::unit_test_framework'
-- Conan: Component target declared 'boost::wave'
-- Conan: Component target declared 'boost::context'
-- Conan: Component target declared 'boost::contract'
-- Conan: Component target declared 'boost::coroutine'
-- Conan: Component target declared 'boost::fiber'
-- Conan: Component target declared 'boost::fiber_numa'
-- Conan: Component target declared 'boost::graph'
-- Conan: Component target declared 'boost::iostreams'
-- Conan: Component target declared 'boost::locale'
-- Conan: Component target declared 'boost::log'
-- Conan: Component target declared 'boost::log_setup'
-- Conan: Target declared 'boost::boost'
-- Conan: Target declared 'bzip2::bzip2'
-- Conan: Target declared 'ZLIB::ZLIB'
-- Conan: Target declared 'libbacktrace::libbacktrace'
-- Conan: Component target declared 'GTest::gtest'
-- Conan: Component target declared 'GTest::gtest_main'
-- Conan: Component target declared 'GTest::gmock'
-- Conan: Component target declared 'GTest::gmock_main'
-- Conan: Target declared 'gtest::gtest'
-- Conan: Component target declared 'GTest::gtest'
-- Conan: Component target declared 'GTest::gtest_main'
-- Conan: Component target declared 'GTest::gmock'
-- Conan: Component target declared 'GTest::gmock_main'
-- Conan: Target declared 'gtest::gtest'
-- Configuring done
-- Generating done
-- Build files have been written to: /root/.conan/data/maze/0.1.0/_/_/build/5f5fdaf06f8bd18961521dbe87621377ba962aa5
maze/0.1.0: CMake command: cmake --build '/root/.conan/data/maze/0.1.0/_/_/build/5f5fdaf06f8bd18961521dbe87621377ba962aa5' '--' '-j12'
[ 7%] Building CXX object config/CMakeFiles/Configs.dir/src/StartupConfig.cpp.o
[ 14%] Building CXX object generator/CMakeFiles/Generator.dir/src/MazeGenerator.cpp.o
[ 21%] Building CXX object solver/CMakeFiles/Solver.dir/src/MazeSolver.cpp.o
/root/.conan/data/maze/0.1.0/_/_/build/5f5fdaf06f8bd18961521dbe87621377ba962aa5/config/src/StartupConfig.cpp:5:10: fatal error: boost/program_options.hpp: No such file or directory
5 | #include <boost/program_options.hpp>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [config/CMakeFiles/Configs.dir/build.make:76: config/CMakeFiles/Configs.dir/src/StartupConfig.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:203: config/CMakeFiles/Configs.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
Do I miss a configuration in ConanFile ?
Could you propose more idiomatic way so that CMake find packages as required in ConanFile ?
As proposed by #Tsyvarev, changing INTERFACE by PRIVATE in target_link_libraries(${PROJECT_NAME} INTERFACE boost::boost boost::program_options) resolved my issue.
For more details, I recommend reading this clarification about CMake scope meaning:
https://leimao.github.io/blog/CMake-Public-Private-Interface/
So I'm trying to get my cmake to work with conan/boost. For this I have a simple conan file:
from conans import ConanFile
class Boost_Conan_Cmake_MinimalConfig(ConanFile):
name = "Boost_Conan_Cmake_MinimalConfig"
generators = "cmake"
options = {"shared": [True, False], "st": [True, False]}
default_options = {"shared": False, "st": True}
def requirements(self):
self.requires("boost/1.69.0#_/_")
self.options["boost"].shared = False
I call this via conan install . --build=missing. This runs perfectly fine and installs boost without problems. When investigating into the folder you can also find all the boost libraries etc.
Next comes my CMakeList.txt. It's pretty straight forward:
cmake_minimum_required(VERSION 3.0)
# CHANGE PROJECT NAME, SOURCES AND DEPENDANT TARGETS
project(boost-conan CXX)
include(conanbuildinfo.cmake)
conan_basic_setup()
set(TARGET_NAME ${PROJECT_NAME})
set(${TARGET_NAME}_SRC src/main.cpp)
find_package(Boost 1.69.0 REQUIRED COMPONENTS filesystem)
add_executable(test "src/main.cpp")
target_include_directories(test PUBLIC $(Boost_INCLUDE_DIRS))
target_link_libraries(test Boost::filesystem)
However, when I try to run this CMake file I get an error:
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19041.
-- The CXX compiler identification is MSVC 19.26.28805.0
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual
Studio/2019/Community/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual
Studio/2019/Community/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Conan: Adjusting output directories
-- Conan: Using cmake global configuration
-- Conan: Adjusting default RPATHs Conan policies
-- Conan: Adjusting language standard
-- Current conanbuildinfo.cmake directory: D:/boost-conan
-- WARN: CONAN_COMPILER variable not set, please make sure yourself that your compiler and version
matches your declared settings
CMake Error at C:/Program Files/CMake/share/cmake-
3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
Could NOT find Boost (missing: filesystem) (found suitable version
"1.69.0", minimum required is "1.69.0")
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393(_FPHSA_FAILURE_MESSAGE)
C:/Program Files/CMake/share/cmake-3.16/Modules/FindBoost.cmake:2179 (find_package_handle_standard_args)
CMakeLists.txt:11 (find_package)
-- Configuring incomplete, errors occurred!
See also "D:/boost-conan/CMakeFiles/CMakeOutput.log".
Does anyone have an idea how to fix this? Or does anyone have an idea why this error occurs? The Error message alone doesn't really help...
Thanks in advance!