I have the CMakeLists.txt for building tests using g++:
file(GLOB sources *.cpp)
foreach(src ${sources})
get_filename_component(src ${src} NAME_WE)
string(REPLACE "our_prefix" "" bin ${src})
add_executable(${bin} ${src})
target_link_libraries(${bin} our options go here)
endforeach()
What I need to do is to add the option -nodefaultlibs to each test. I've tried to do it like this:
file(GLOB sources *.cpp)
foreach(src ${sources})
get_filename_component(src ${src} NAME_WE)
string(REPLACE "our_prefix" "" bin ${src})
add_executable(${bin} ${src})
set_target_properties(${bin} PROPERTIES
INTERFACE_COMPILE_OPTIONS "-nodefaultlibs"
)
target_link_libraries(${bin} our options go here)
endforeach()
But it seems to have no effect. I've also tried to use the command target_compile_options instead of set_target_properties - and it also had no effect.
Cmake generates the link.txt file for each test - I suppose this file describes the building command used for the test. This file doesn't contain my option -nodefaultlibs.
Could you please explain me what is the right way to add the -nodefaultlibs option?