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()

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)
    if(CMAKE_BUILD_TYPE STREQUAL "Debug")
        target_compile_definitions(${binary_name} PRIVATE "ENABLE_ASSERT")
    endif()
    add_test(NAME ${binary_name} COMMAND ${binary_name})
endforeach()

Enable assertions in debug mode
Enable assertions in debug mode
