I'm using CMake to compile my C project and I have dependency, which is downloaded using FetchContent
, but by default, that dependency is using exceptions, that are disabled in my project and so I have to pass preprocessor definition to this dependency to disable them. This is what I do:
FetchContent_Declare(
sioclient
GIT_REPOSITORY https://github.com/socketio/socket.io-client-cpp.git
GIT_TAG 3.1.0
)
FetchContent_MakeAvailable(sioclient)
add_compile_definitions("_WEBSOCKETPP_NO_EXCEPTIONS_")
Looks like CMake passes add_compile_definitions
into anything in my project, but not into dependency. How can I set preprocessor definitions for dependencies downloaded and populated by FetchContent
?
CodePudding user response:
It seams to work when add_compile_definitions(_WEBSOCKETPP_NO_EXCEPTIONS_)
is added before the FetchContent stuff.
Or alternatively, it works with a target specific definition:
target_compile_definitions(sioclient PUBLIC _WEBSOCKETPP_NO_EXCEPTIONS_)