Reputation: 1623
I'm run into a problem where Cmake is missing a dependency. The code in question looks like.
SUBROUTINE foo
USE A
#ifdef C
USE B
#endif
...
It looks like the preprocessor blocked portion is getting excluded when generating the dependencies. This is causing an error because module B never gets built before this source file. How can I resolve this?
Update:
I'm setting the preprocessor define here.
add_library (abc STATIC ${abc_sources})
set_target_properties (abc PROPERTIES COMPILE_FLAGS "${BUILD_FLAGS} -D C")
Upvotes: 1
Views: 895
Reputation: 1623
Figured it out. The correct solution is use
set_target_properties (abc PROPERTIES COMPILE_DEFINITIONS "C")
COMPILE_DEFINITIONS
is the set_target_properties
anaglog to add_definitions
.
Upvotes: 2