69e2f1d3e3
MSVC's C4062 is off by default and GCC/Clang's -Wswitch only warns without -Werror; this repo sets no -Wall/-Werror anywhere. /we4062 and -Werror=switch now cover both, scoped to pure libraries only.
36 lines
1.9 KiB
CMake
36 lines
1.9 KiB
CMake
# The two shapes that repeat across src/: a pure static library and its CTest target.
|
|
# Both are thin pass-throughs — LINK is forwarded to target_link_libraries verbatim, so
|
|
# PUBLIC/PRIVATE keywords and link order stay visible at the call site rather than being
|
|
# invented by the helper. Targets that genuinely deviate are written out longhand.
|
|
|
|
# Every pure library carries src/ as a PUBLIC include dir: headers are included rooted
|
|
# there ("core/json/json.h"), so a consumer needs only the link edge.
|
|
function(reasampler_pure_library name)
|
|
cmake_parse_arguments(ARG "" "" "SOURCES;LINK" ${ARGN})
|
|
add_library(${name} STATIC ${ARG_SOURCES})
|
|
target_include_directories(${name} PUBLIC ${REASAMPLER_SRC_DIR})
|
|
if(ARG_LINK)
|
|
target_link_libraries(${name} ${ARG_LINK})
|
|
endif()
|
|
# A default-less switch missing an enumerator: MSVC's C4062 is off by its /W1 default;
|
|
# GCC/Clang's -Wswitch is on by default but only warns without -Werror, and this repo
|
|
# sets no -Wall/-Werror/-W4/-WX anywhere. Promoted to an error only here, on our own
|
|
# pure libraries, so a deliberately default-less switch (e.g. isLiveDeckParam,
|
|
# deck_groups.cpp) is a compile error on every toolchain. NOT C4061 (fires even with
|
|
# a default: present) — that would light up every defensive switch in the tree.
|
|
if(MSVC)
|
|
target_compile_options(${name} PRIVATE /we4062)
|
|
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
|
target_compile_options(${name} PRIVATE -Werror=switch)
|
|
endif()
|
|
endfunction()
|
|
|
|
# Test naming is exceptionless: target <name>_tests is built from tests/test_<name>.cpp
|
|
# and registered under its own target name.
|
|
function(reasampler_test name)
|
|
cmake_parse_arguments(ARG "" "" "LINK" ${ARGN})
|
|
add_executable(${name}_tests ${REASAMPLER_TESTS_DIR}/test_${name}.cpp)
|
|
target_link_libraries(${name}_tests PRIVATE ${ARG_LINK})
|
|
add_test(NAME ${name}_tests COMMAND ${name}_tests)
|
|
endfunction()
|