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/
Related
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
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
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!
When using this CMakeLists.txt
cmake_minimum_required(VERSION 3.17)
project(project_c)
set(CMAKE_CXX_STANDARD 11)
set(project_name project_c)
find_package(BISON)
find_package(FLEX)
BISON_TARGET(parser parser.y ${CMAKE_SOURCE_DIR}/parser.cpp)
FLEX_TARGET(lexer lexer.l ${CMAKE_SOURCE_DIR}/lexer.cpp)
ADD_FLEX_BISON_DEPENDENCY(lexer parser)
add_executable(${project_name} ${BISON_parser_OUTPUTS} ${FLEX_lexer_OUTPUTS})
target_include_directories(${project_name} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
target_link_libraries(${project_name} ${FLEX_LIBRARIES})
CMake complains about
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
FL_LIBRARY (ADVANCED)
linked by target "project_c" in directory D:/asant/workspace/CLionProjects/project_c
I've tried to copy the winflex folder inside the project folder but that won't help anyway. This proposed solution isn't working.
This is the complete CMake log
"C:\Program Files\JetBrains\CLion 2018.3.4\bin\cmake\win\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - MinGW Makefiles" D:\asant\workspace\CLionProjects\project_c
-- The C compiler identification is GNU 8.1.0
-- The CXX compiler identification is GNU 8.1.0
-- Check for working C compiler: C:/Qt/Tools/mingw810_64/bin/gcc.exe
-- Check for working C compiler: C:/Qt/Tools/mingw810_64/bin/gcc.exe - 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: C:/Qt/Tools/mingw810_64/bin/g++.exe
-- Check for working CXX compiler: C:/Qt/Tools/mingw810_64/bin/g++.exe - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found BISON: C:/Program Files (x86)/win_flex_bison-2.5.23/win_bison.exe (found version "3.7.1")
-- Found FLEX: C:/Program Files (x86)/win_flex_bison-2.5.23/win_flex.exe (found version "2.6.4")
-- Configuring done
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
FL_LIBRARY (ADVANCED)
linked by target "project_c" in directory D:/asant/workspace/CLionProjects/project_c
-- Generating done
CMake Generate step failed. Build files cannot be regenerated correctly.
[Failed to reload]
I would like to use the NetCDF API in my C++ projects.
In the offical web site documentation, I saw that this C++ interface have a compilation dependency of NetCDF-C library.
I already downloaded binary NetCDF-C installer (called netCDF4.7.1-NC4-DAP-64.exe) from the offical website (link here) installed it and add the installed folder to my PATH.
C:\Program Files\netCDF 4.7.1\
So I tested it in the Windows console runing: ncdump.exe ...and all works good!
Now I cloned the NetCDF-CXX4 repository (link here) and tried to compile it, but I got a lot of CMake errors.
My system is:
Windows 10 x64
Visual Studio 2019 Enterprise
CMake 3.14.4
NetCDF-CXX 4.3.1
What I did
Inside the cloned NetCDF-CXX4 folder, I created a folder called "build".
Inside the build folder I typed: cmake ..
Here is the console error
cmake ..
-- Building for: Visual Studio 16 2019
-- The C compiler identification is MSVC 19.23.28105.4
-- The CXX compiler identification is MSVC 19.23.28105.4
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64/cl.exe -- 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: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.23.28105/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
-- Found bash: C:/Program Files/Git/usr/bin/bash.exe
-- Looking for nc_use_parallel_enabled in netcdf
CMake Error at C:/Users/lamar/Desktop/netcdf-cxx4-4.3.1/build/CMakeFiles/CMakeTmp/CMakeLists.txt:17 (add_executable):
Target "cmTC_7cc31" links to target "hdf5::hdf5-shared" but the target was
not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?
CMake Error at C:/Users/lamar/Desktop/netcdf-cxx4-4.3.1/build/CMakeFiles/CMakeTmp/CMakeLists.txt:17 (add_executable):
Target "cmTC_7cc31" links to target "hdf5::hdf5_hl-shared" but the target
was not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?
CMake Error at C:/Users/lamar/Desktop/netcdf-cxx4-4.3.1/build/CMakeFiles/CMakeTmp/CMakeLists.txt:17 (add_executable):
Target "cmTC_7cc31" links to target "hdf5::hdf5-shared" but the target was
not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?
CMake Error at C:/Users/lamar/Desktop/netcdf-cxx4-4.3.1/build/CMakeFiles/CMakeTmp/CMakeLists.txt:17 (add_executable):
Target "cmTC_7cc31" links to target "hdf5::hdf5_hl-shared" but the target
was not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?
CMake Error at C:/Users/lamar/Desktop/netcdf-cxx4-4.3.1/build/CMakeFiles/CMakeTmp/CMakeLists.txt:17 (add_executable):
Target "cmTC_7cc31" links to target "hdf5::hdf5-shared" but the target was
not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?
CMake Error at C:/Users/lamar/Desktop/netcdf-cxx4-4.3.1/build/CMakeFiles/CMakeTmp/CMakeLists.txt:17 (add_executable):
Target "cmTC_7cc31" links to target "hdf5::hdf5_hl-shared" but the target
was not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?
CMake Error at C:/Users/lamar/Desktop/netcdf-cxx4-4.3.1/build/CMakeFiles/CMakeTmp/CMakeLists.txt:17 (add_executable):
Target "cmTC_7cc31" links to target "hdf5::hdf5-shared" but the target was
not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?
CMake Error at C:/Users/lamar/Desktop/netcdf-cxx4-4.3.1/build/CMakeFiles/CMakeTmp/CMakeLists.txt:17 (add_executable):
Target "cmTC_7cc31" links to target "hdf5::hdf5_hl-shared" but the target
was not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?
CMake Error at C:/Users/lamar/Desktop/netcdf-cxx4-4.3.1/build/CMakeFiles/CMakeTmp/CMakeLists.txt:17 (add_executable):
Target "cmTC_7cc31" links to target "hdf5::hdf5-shared" but the target was
not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?
CMake Error at C:/Users/lamar/Desktop/netcdf-cxx4-4.3.1/build/CMakeFiles/CMakeTmp/CMakeLists.txt:17 (add_executable):
Target "cmTC_7cc31" links to target "hdf5::hdf5_hl-shared" but the target
was not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?
CMake Error at C:/Program Files/cmake/share/cmake-3.14/Modules/CheckLibraryExists.cmake:67 (try_compile):
Failed to generate test project build system.
Call Stack (most recent call first):
CMakeLists.txt:382 (CHECK_LIBRARY_EXISTS)
-- Configuring incomplete, errors occurred!
See also "C:/Users/lamar/Desktop/netcdf-cxx4-4.3.1/build/CMakeFiles/CMakeOutput.log".
What I have to do to build the NetCDF-CXX4 static/dynamic libraries in my system?