Open Pibben opened 1 month ago
Hi @Pibben
Thanks for your question
conan install .. --build=missing --output-folder conan-gen -s build_type=Release -pr:b default -pr:h ../tools/windows-cross -c tools.cmake.cmaketoolchain:user_toolchain="[\"$PWD/../tools/mingw-w64-x86_64.cmake\"]"
A few suggestions:
-s build_type=Release
is redundant here-c
confs can better be put in the profile too, in the [conf]
section--output-folder
is better managed with the [layout]
section, defining cmake_layout
. This allows for creating automatically different subfolders and CMake presets for each one, and allows configuration of those folders and presets with tools.cmake.cmaketoolchain:build_folder_vars
conf. It seems this is what you want to do, and it can be done in a structured and automatic way.With the above, the flow can be:
# Note it is not even necessary to change folder, can be done in root
$ conan install . --build=missing -pr:h ../tools/windows-cross
$ cmake --preset conan-default
Thanks for your comments!
Why is it better to put the -c
confs in the profile? Besides less typing on the command line.
Why is it better to put the -c confs in the profile? Besides less typing on the command line.
Not only less typing, it is also the cognitive overhead, avoiding errors, etc.
The profiles can be shared with conan config install
, that means that you might update your mingw-w64-x86_64.cmake
file, even change the filename, update its contents, and all developers and CI machines will just do conan config install
+ conan install . --build=missing -pr:h ../tools/windows-cross
. The contents of the mingw-w64-x86_64.cmake
can be shared together with the profile too in the same conan config install
Other side note, the CONAN_CMAKE_GENERATOR
env-variables are no longer used in Conan2 (or in Conan 1 new integrations), the have been replaced by confs like tools.cmake.cmaketoolchain:generator
What is your question?
With Conan 1 i did:
conan install .. -pr:b=default -pr:h=../tools/windows-cross --build=missing
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=mingw-w64-x86_64.cmake
Where windows-cross looked like this:
and mingw-w64-x86_64.cmake:
Now with Conan 2 I do:
conan install .. --build=missing --output-folder conan-gen -s build_type=Release -pr:b default -pr:h ../tools/windows-cross -c tools.cmake.cmaketoolchain:user_toolchain="[\"$PWD/../tools/mingw-w64-x86_64.cmake\"]"
cmake .. -DCMAKE_TOOLCHAIN_FILE=conan-gen/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release
with windows-cross now looking like this:
I use
--output-folder conan-gen
because I want to have the generated files in the build directory so that I can have several cross builds in parallellIs this the way to do it? Any suggestions welcome.
Have you read the CONTRIBUTING guide?