-
Notifications
You must be signed in to change notification settings - Fork 45
/
formatPEConfig.cmake
81 lines (57 loc) · 1.89 KB
/
formatPEConfig.cmake
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
if(NOT DEFINED formatPE_NAME)
set(formatPE_NAME "formatPE")
endif()
if(NOT DEFINED PLATFORM_DIR)
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4")
set(PLATFORM_DIR "x86")
else()
set(PLATFORM_DIR "x64")
endif()
endif()
# formatPE::Pe is header-only:
add_library("${formatPE_NAME}_Pe" INTERFACE)
target_include_directories("${formatPE_NAME}_Pe" INTERFACE
"${CMAKE_CURRENT_LIST_DIR}/formatPE/"
)
add_library("${formatPE_NAME}::Pe" ALIAS "${formatPE_NAME}_Pe")
# formatPE::Pdb library:
add_library("${formatPE_NAME}_Pdb"
"${CMAKE_CURRENT_LIST_DIR}/formatPE/Pdb/Pdb.h"
"${CMAKE_CURRENT_LIST_DIR}/formatPE/Pdb/Pdb.cpp"
)
target_include_directories("${formatPE_NAME}_Pdb" PUBLIC
"${CMAKE_CURRENT_LIST_DIR}/formatPE/"
)
add_library("${formatPE_NAME}::Pdb" ALIAS "${formatPE_NAME}_Pdb")
# formatPE::SymLoader library:
add_library("${formatPE_NAME}_SymLoader"
"${CMAKE_CURRENT_LIST_DIR}/formatPE/Pdb/SymLoader.h"
"${CMAKE_CURRENT_LIST_DIR}/formatPE/Pdb/SymLoader.cpp"
)
target_include_directories("${formatPE_NAME}_SymLoader" PUBLIC
"${CMAKE_CURRENT_LIST_DIR}/formatPE/"
)
target_link_libraries("${formatPE_NAME}_SymLoader" PUBLIC
formatPE::Pe
formatPE::Pdb
)
add_library("${formatPE_NAME}::SymLoader" ALIAS "${formatPE_NAME}_SymLoader")
# Tests:
add_executable("PeTests" "${CMAKE_CURRENT_LIST_DIR}/PeTests/PeTests.cpp")
target_link_libraries("PeTests" PUBLIC
formatPE::Pe
formatPE::Pdb
formatPE::SymLoader
)
enable_testing()
add_test("PeTests" "${CMAKE_BINARY_DIR}/${PLATFORM_DIR}/bin/PeTests.exe")
set_target_properties(
"${formatPE_NAME}_Pe"
"${formatPE_NAME}_Pdb"
"${formatPE_NAME}_SymLoader"
"PeTests"
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${PLATFORM_DIR}/lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${PLATFORM_DIR}/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${PLATFORM_DIR}/bin"
)