Reputation: 940
I am trying the example below :
add_library(
mylib
src/my_code.cpp)
target_include_directories(mylib
PUBLIC include ${catkin_INCLUDE_DIRS} ${thirdPartyLib_INCLUDE_DIRS})
add_dependencies(
mylib
${mylib_EXPORTED_TARGETS}
${catkin_EXPORTED_TARGETS})
target_link_libraries(mylib
PUBLIC
${thirdPartyLib_LIBRARY} ${catkin_LIBRARIES})
target_compile_options(mylib PRIVATE -Werror -Wall -Wextra)
The issue is that the compile options also propagate to thirdPartyLib
, yet I need them only for mylib
.
Upvotes: 2
Views: 350
Reputation: 301
I think that the problem is compiler warnings, which are generated by included thirdPartyLib
header files when compiling file my_code.cpp
.
If you want your compiler not to generate warnings from included third-party header files, you can for example in gcc/clang include them as "system headers" (command line option -isystem
instead of -I
).
To do this in CMake use SYSTEM
option in target_include_directories
:
target_include_directories(mylib
SYSTEM
PUBLIC ${thirdPartyLib_INCLUDE_DIRS}
)
Upvotes: 1