New-Cli-Installer/gucc/tests/CMakeLists.txt
2024-07-11 03:44:16 +04:00

23 lines
922 B
CMake

#############################################################################
# one executable for each unit test file
#############################################################################
file(GLOB files unit-*.cpp)
set(GUCC_TEST_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(GUCC_TOP_DIR "${CMAKE_SOURCE_DIR}")
foreach(file ${files})
get_filename_component(file_basename ${file} NAME_WE)
string(REGEX REPLACE "unit-([^$]+)" "test-\\1" testcase ${file_basename})
add_executable(${testcase} ${file})
target_compile_options(${testcase} PRIVATE
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-deprecated;-Wno-float-equal>
$<$<CXX_COMPILER_ID:GNU>:-Wno-deprecated-declarations>
)
add_definitions(-DGUCC_TEST_DIR="${GUCC_TEST_DIR}")
add_definitions(-DGUCC_TOP_DIR="${GUCC_TOP_DIR}")
target_link_libraries(${testcase} PRIVATE project_warnings project_options gucc::gucc)
endforeach()