cmake-conan
cmake-conan copied to clipboard
what is the equivalent of `add_compile_options` in cmake
I want to set some compile flags when building a package and it can be done with add_compile_options in CMake. How should I do in conanfile.py. I've searched for a while but didn't get an answer. CONAN_CXX_FLAGS didn't work
The flag I want to add is /Zc:__cplusplus on MSVC
CUrrently I use self._cmake.definitions["CMAKE_CXX_FLAGS"] = "/EHsc /Zc:__cplusplus" but I don't know if this is a good idea.
Hi @maidamai0,
Can you provide more information about your use case? Are you using cmake-conan to create a package or just for consuming other packages.
If you are using cmake-conan as a consumer you should add those in the CMakeLists.txt directly using add_compile_options.
In the case you re you creating a package and you want to use those flags when building, yes, you could add those flags to definitions using the self._cmake.definitions.
Thank you @czoido
I'm creating a package with conan. I'm concering if self._cmake.definitions["CMAKE_CXX_FLAGS"] = "/EHsc /Zc:__cplusplus" overrides the flags set before