您可以在INTERFACE库(foo)上设置COMPILE_OPTIONS ,这些COMPILE_OPTIONS也将由foo的用户使用 .
add_library(foo INTERFACE)
target_link_libraries(foo INTERFACE foo_1)
target_compile_options(foo INTERFACE "-DSOME_DEFINE")
add_executable(exe exe.cpp)
target_link_libraries(exe foo)
Run Code Online (Sandbox Code Playgroud)
是否可以为LINK_FLAGS做类似的事情?
cmake ×1