cmake-conan
cmake-conan copied to clipboard
Preprocessor definitions are not set.
I am trying to use asio in conan build setup. https://github.com/conan-io/conan-center-index/tree/master/recipes/asio/all
its conanfile.py has this
def package_info(self):
self.cpp_info.defines.append('ASIO_STANDALONE')
if str(self.settings.os) in ["Linux", "Android"]:
self.cpp_info.libs.append('pthread')
When I add asio as an dependecy in my conanfile.py, the generated conanbuildinfo.cmake has these,
set(CONAN_DEFINES "-DASIO_STANDALONE" ${CONAN_DEFINES})
..............
..............
add_compile_options(${CONAN_DEFINES}
"$<$<CONFIG:Debug>:${CONAN_DEFINES_DEBUG}>"
"$<$<CONFIG:Release>:${CONAN_DEFINES_RELEASE}>"
"$<$<CONFIG:RelWithDebInfo>:${CONAN_DEFINES_RELWITHDEBINFO}>"
"$<$<CONFIG:MinSizeRel>:${CONAN_DEFINES_MINSIZEREL}>")
But ASIO_STANDALONE is not defined in the project. I think the correct CMAKE function for defining compiler definitions is add_definitions.
Am I missing something here? or asio is not setting up definitions correctly?
Hi @asankacoder, Thanks for your feedback. The main reason for using that instead of add_definitions in Conan is that there's the possibility to do something like this in the recipes:
self.cpp_info.debug.defines.append('DEFINITION_DEBUG')
self.cpp_info.release.defines.append('DEFINITION_RELEASE')
So, for resolving that you need generator expressions that you can have in add_compile_options.
Are you having issues because of this?