如何添加 conan CMake 构建定义
使用 conan 构建库时,这是使用 CMake 构建的默认 conanfile.py 定义
conan_cmake_example.py
cmake = CMake(self)
cmake.configure(source_folder="hello")
cmake.build()你可以像这样轻松添加定义:
conan_cmake_definition.py
cmake.definitions["MY_FLAG"] = "1"调用 CMake 时这将生成 -DMY_FLAG=1
完整示例:
conan_cmake_full.py
cmake = CMake(self)
cmake.definitions["USE_SYSTEM_CPR"] = "1
cmake.configure(source_folder="elasticlient")"
cmake.build()注意你需要在调用 cmake.configure() 之前添加所有 cmake.definitions 调用
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow