I have written a small library that uses doctest. In CMakeLists.txt I have:
...
add_library(my_lib STATIC ${SRCS} $<TARGET_OBJECTS:common_files>)
add_executable(tests ${SRCS} $<TARGET_OBJECTS:common_files>)
target_compile_definitions(my_lib PRIVATE -DDOCTEST_CONFIG_DISABLE)
...
When using the library in a project via add_subdirectory
, the library and the test executable are built when I just need the library.
What can I do to prevent tests being built when including the CMakeLists.txt as a subdirectory, or is there a better way of achieving a similar result?
Aucun commentaire:
Enregistrer un commentaire