Files
ImHex-Patterns/tests/includes/CMakeLists.txt
BobSmun e026ff187e build: Improve build system (#327)
* *Add top level CMakeLists.txt, to make it easier to use both independently and from within other projects
* Add a unit_test target, to attach all unit tests to

* * Fix unit tests for windows
* Silence cmake warning regarding missing top project
* update .gitignore for vscode

---------

Co-authored-by: BobSmun <6492115+BobSmun@users.noreply.github.com>
2024-12-16 20:37:38 +01:00

31 lines
972 B
CMake

cmake_minimum_required(VERSION 3.16)
project(includes_test)
set(TOP_LEVEL "${CMAKE_CURRENT_SOURCE_DIR}/../..")
file(GLOB INCLUDES
"${TOP_LEVEL}/includes/*/*.pat"
)
set(PATTERN_INCLUDES "${TOP_LEVEL}/includes")
add_executable(includes_test
source/main.cpp
)
target_include_directories(includes_test PRIVATE include)
target_link_libraries(includes_test PRIVATE libpl fmt::fmt-header-only)
set_target_properties(includes_test PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
message(STATUS "Adding Include Tests")
foreach (include IN LISTS INCLUDES)
file(RELATIVE_PATH INCLUDE_NAME ${PATTERN_INCLUDES} ${include})
set(TEST_NAME "Includes/${INCLUDE_NAME}")
add_test(NAME ${TEST_NAME} COMMAND includes_test "${INCLUDE_NAME}" "${include}" "${PATTERN_INCLUDES}" WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set_tests_properties(${TEST_NAME} PROPERTIES SKIP_RETURN_CODE 77)
endforeach ()
add_dependencies(unit_tests ${PROJECT_NAME})