• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Unit tests are written using the Boost unit test framework
2find_package(Boost REQUIRED COMPONENTS unit_test_framework)
3
4# Find all the binary files used for testing and copy them into the build
5# directory. This allows the test to be run from the build directory
6
7# First, create an elf_examples folder under the current build directory
8file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/elf_examples)
9
10# Second, glob all files under elf_examples
11file(GLOB elf_examples
12    LIST_DIRECTORIES
13        false
14    CONFIGURE_DEPENDS
15    elf_examples/*)
16
17# Third, copy each file globbed to the elf_examples folder under the current
18# build directory
19foreach(example ${elf_examples})
20    configure_file(${example} ${CMAKE_CURRENT_BINARY_DIR}/elf_examples COPYONLY)
21endforeach()
22
23# Lastly, copy the script to run the tests
24configure_file(runELFtests ${CMAKE_CURRENT_BINARY_DIR}/runELFtests COPYONLY)
25
26add_executable(
27    ELFIOTest
28    ELFIOTest.cpp
29    ELFIOTest1.cpp
30    ELFIOTest2.cpp)
31
32target_link_libraries(
33    ELFIOTest
34    PRIVATE
35        elfio::elfio
36        Boost::unit_test_framework)
37
38add_test(
39    NAME
40        ELFIOTest
41    COMMAND
42        ${CMAKE_CURRENT_BINARY_DIR}/ELFIOTest
43    WORKING_DIRECTORY
44        ${CMAKE_CURRENT_BINARY_DIR})
45
46add_dependencies(check ELFIOTest)
47