We have a C++ project with a conanfile.txt
:
[requires]
libpqxx/7.8.1
pistache/cci.20240107
nlohmann_json/3.11.3
...
[generators]
CMakeDeps
CMakeToolchain
[layout]
cmake_layout
and a CMakeList.txt
:
cmake_minimum_required(VERSION 3.18.4)
project(CPPTemplate)
include(CTest)
set (CMAKE_CXX_STANDARD 17)
##### Prepare environment #####
set(CMAKE_MODULE_PATH ./build/build/Debug/generators/)
###############################
include_directories(./src)
add_subdirectory(src)
if (BUILD_TESTING)
include_directories(./testFolder)
add_subdirectory(testFolder)
endif()
both files at its root.
Our instructions are to build our application, the first time, by running the following commands in a shell:
conan profile detect --force
conan install . -of=build -b=missing -s compiler.cppstd=gnu17
cmake -S . -B ./build/ -DCMAKE_TOOLCHAIN_FILE=./build/build/Debug/generators/conan_toolchain.cmake
cmake --build ./build/
and / or:
conan install . -of=build -b=missing -s compiler.cppstd=gnu17 --settings=build_type=Debug
cmake -S . -B ./build/ -DCMAKE_TOOLCHAIN_FILE=./build/build/Debug/generators/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Debug
cmake --build ./build/
if we are willing the application in Debug mode too.
At the end of the building process, we have our binary,
but if we attempt to build both Debug then Release, our build directory looks like that:
(…with a lot of .cmake
files …)
And our IDE, VSCode in this example here,
cannot find the underlying profiles conan-release
and conan-debug
(profile, preset ? are these words synonyms?) that are generated during this process,
in order to use them to launch and debug the application from the IDE.
Sometimes CLion looks more sucessful at their detection, but it really seems that we are doing mistakes.
Things look like we would be generating (by the mean of the command lines) something that isn’t conforming to what a C++ IDE can expect from a C++ project structure, in order to retrieve information about existing CMake profiles.
We are beginners at CMake and Conan management. Is there some troubles you can see in what we have done?
Thanks!