ELFIO/tests/CMakeLists.txt

61 lines
1.5 KiB
CMake
Raw Normal View History

2022-02-11 21:15:39 +00:00
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/9a32aee22d771387c494be2d8519fbdf46a713b2.zip
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
enable_testing()
2020-10-16 07:14:56 +00:00
# Find all the binary files used for testing and copy them into the build
# directory. This allows the test to be run from the build directory
2020-10-16 07:14:56 +00:00
# First, create an elf_examples folder under the current build directory
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/elf_examples)
# Second, glob all files under elf_examples
file(GLOB elf_examples
LIST_DIRECTORIES
false
CONFIGURE_DEPENDS
elf_examples/*)
# Third, copy each file globbed to the elf_examples folder under the current
# build directory
foreach(example ${elf_examples})
configure_file(${example} ${CMAKE_CURRENT_BINARY_DIR}/elf_examples COPYONLY)
endforeach()
# Lastly, copy the script to run the tests
configure_file(runELFtests ${CMAKE_CURRENT_BINARY_DIR}/runELFtests COPYONLY)
add_executable(
ELFIOTest
ELFIOTest.cpp
ELFIOTest1.cpp
ELFIOTest2.cpp)
target_link_libraries(
ELFIOTest
PRIVATE
elfio::elfio
2022-02-11 21:15:39 +00:00
gtest_main)
add_test(
NAME
ELFIOTest
COMMAND
${CMAKE_CURRENT_BINARY_DIR}/ELFIOTest
WORKING_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR})
2020-10-29 22:49:12 +00:00
add_dependencies(check ELFIOTest)
2022-02-11 21:15:39 +00:00
include(GoogleTest)
gtest_discover_tests(ELFIOTest)