enable_language(C) file(GLOB files "*.cpp" "*.c") foreach(file ${files}) get_filename_component(binary_name ${file} NAME_WE) add_executable(${binary_name} ${file}) target_link_libraries(${binary_name} primesieve::primesieve) add_test(NAME ${binary_name} COMMAND ${binary_name}) endforeach()