How to add conan CMake build definition
When building a library using conan, this is the default conanfile.py definition for building using CMake
conan_cmake_example.py
cmake = CMake(self)
cmake.configure(source_folder="hello")
cmake.build()You can easily add definitions like this:
conan_cmake_definition.py
cmake.definitions["MY_FLAG"] = "1"This will generate -DMY_FLAG=1 when calling CMake
Full example:
conan_cmake_full.py
cmake = CMake(self)
cmake.definitions["USE_SYSTEM_CPR"] = "1
cmake.configure(source_folder="elasticlient")"
cmake.build()Note that you need to add all cmake.definitions calls before calling cmake.configure()
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow