AllTargetsCompileOptions.cmake (517B)
1 # Add compile options to all targets added in the subdirectory. 2 function(all_targets_compile_options dir options) 3 get_directory_property(targets DIRECTORY ${dir} BUILDSYSTEM_TARGETS) 4 separate_arguments(options) 5 set(compiled_target_types STATIC_LIBRARY SHARED_LIBRARY OBJECT_LIBRARY EXECUTABLE) 6 foreach(target ${targets}) 7 get_target_property(type ${target} TYPE) 8 if(type IN_LIST compiled_target_types) 9 target_compile_options(${target} PRIVATE ${options}) 10 endif() 11 endforeach() 12 endfunction()