forked from trailofbits/pe-parse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
47 lines (38 loc) · 1.54 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
include(CTest)
# Path for corkami dataset
set(CORKAMI_SUBMODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/assets/corkami-poc-dataset")
set(CORKAMI_PE_PATH "${CORKAMI_SUBMODULE_PATH}/PE/bin")
if (NOT EXISTS "${CORKAMI_PE_PATH}")
message(WARNING "Could not find Corkami dataset for testing.\nUse 'git submodule update --init'")
endif()
# To reconfigure and rebuild when submodule status changes
# See https://gitlab.kitware.com/cmake/cmake/-/issues/18755 to read why using
# (potentially non-existant) CORKAMI_PE_PATH doesn't work
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CORKAMI_SUBMODULE_PATH}")
if (NOT USE_EXTERNAL_CATCH2)
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/catch.cmake.in")
else()
find_package(Catch2 REQUIRED)
endif()
add_executable(tests
test_main.cpp
simple_test.cpp
corkami_test.cpp
filesystem_compat.h
)
target_compile_definitions(tests PRIVATE ASSETS_DIR="${CMAKE_CURRENT_SOURCE_DIR}/assets")
target_link_libraries(tests PRIVATE std::filesystem ${PROJECT_NAME} Catch2::Catch2)
target_include_directories(tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
if (EXISTS "${CORKAMI_PE_PATH}")
target_compile_definitions(tests PRIVATE CORKAMI_PE_PATH="${CORKAMI_PE_PATH}")
endif()
if (WIN32 AND BUILD_SHARED_LIBS)
# Workaround for shared lib loading in Windows.
# Need to copy all dependent DLLs to the same directory
add_custom_command (TARGET tests POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:${PROJECT_NAME}> $<TARGET_FILE_DIR:tests>
)
endif()
include(Catch)
catch_discover_tests(tests)