forked from DFIR-ORC/dfir-orc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
164 lines (135 loc) · 4.81 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
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
cmake_minimum_required(VERSION 3.16)
# CMake user options
option(ORC_USE_STATIC_CRT "Use static runtime" ON)
option(ORC_BUILD_VCPKG "Build vcpkg dependencies" ON)
option(ORC_BUILD_APACHE_ORC "Build Apache's ORC module" OFF)
option(ORC_BUILD_COMMAND "Build any OrcCommand based command" ON)
option(ORC_BUILD_FASTFIND "Build FastFind binary" ON)
option(ORC_BUILD_ORC "Build Orc binary" ON)
option(ORC_BUILD_PARQUET "Build Parquet module" OFF)
option(ORC_BUILD_TLSH "Build with tlsh support" OFF)
option(ORC_BUILD_SSDEEP "Build with ssdeep support" OFF)
option(ORC_BUILD_JSON "Build with JSON StructuredOutput enabled" ON)
option(ORC_BUILD_BOOST_STACKTRACE "Build with stack backtrace enabled" ON)
option(ORC_DOWNLOADS_ONLY "Do not build ORC but only download vcpkg third parties" OFF)
option(ORC_DISABLE_PRECOMPILED_HEADERS "Disable precompiled headers" OFF)
option(ORC_SWAPRUN_NET "Enable PE option to for stable execution from network" ON)
if(NOT ORC_BUILD_COMMAND)
set(ORC_BUILD_FASTFIND OFF)
set(ORC_BUILD_ORC OFF)
endif()
set(ORC_VCPKG_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/external/vcpkg"
CACHE FILEPATH "VCPKG root directory"
)
set(ORC_ICON "${CMAKE_CURRENT_SOURCE_DIR}/res/DFIR-Orc.ico"
CACHE STRING "Application icon"
)
set(ORC_ROOT "${CMAKE_CURRENT_SOURCE_DIR}")
if(ORC_USE_STATIC_CRT)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
else()
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
endif()
# Insert custom cmake directories for script lookup
list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# Default target is 'Windows Seven' unless xp toolset is used
if(NOT CMAKE_SYSTEM_VERSION)
if("${CMAKE_GENERATOR_TOOLSET}" STREQUAL "v141_xp")
set(CMAKE_SYSTEM_VERSION 5.1)
else()
set(CMAKE_SYSTEM_VERSION 6.1)
endif()
endif()
# Setup repository related variables and force refresh on new commits
include(cmake/GitInfo.cmake)
git_monitor_status()
git_info(
REPO_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
VERSION_FROM_SEMVER_TAG ORC_VERSION
BRANCH ORC_BRANCH
COMMIT ORC_COMMIT
)
message(WARNING "BEWARE: VCPKG is currently compatible ONLY with ENGLISH version of Visual Studio.")
# Configure triplet dynamically with options chosen from CMake
set(OVERLAY_TRIPLETS ${CMAKE_BINARY_DIR}/vcpkg/triplets)
include(cmake/vcpkg_configure_triplets.cmake)
vcpkg_configure_triplets(OUTPUT_TRIPLETS_DIR ${OVERLAY_TRIPLETS})
include(cmake/architecture.cmake)
get_target_architecture(RESULT_VARIABLE "TARGET_ARCH")
if(${TARGET_ARCH} STREQUAL "x86")
set(ORC_BUILD_PARQUET OFF)
endif()
# Build the required package dependency list
if(ORC_VCPKG_ROOT)
list(APPEND _PACKAGES
7zip
boost-algorithm
boost-dynamic-bitset
boost-logic
boost-multi-index
boost-outcome
boost-scope-exit
fmt
spdlog
yara
rapidjson
)
# Tools/rcedit specific dependencies
list(APPEND _PACKAGES
cli11
)
if(ORC_BUILD_BOOST_STACKTRACE)
add_compile_definitions(ORC_BUILD_BOOST_STACKTRACE)
list(APPEND _PACKAGES boost-stacktrace)
endif()
if(ORC_BUILD_TLSH)
add_definitions(-DORC_BUILD_TLSH)
list(APPEND _PACKAGES tlsh)
endif()
if(ORC_BUILD_APACHE_ORC)
if("${CMAKE_GENERATOR_TOOLSET}" STREQUAL "v141_xp")
message(FATAL_ERROR "Apache Orc requires Seven or later")
endif()
list(APPEND _PACKAGES orc)
endif()
if(ORC_BUILD_PARQUET)
list(APPEND _PACKAGES arrow)
endif()
if(ORC_BUILD_SSDEEP)
add_definitions(-DORC_BUILD_SSDEEP)
list(APPEND _PACKAGES ssdeep)
endif()
if(ORC_DOWNLOADS_ONLY)
set(ONLY_DOWNLOADS "ONLY_DOWNLOADS")
endif()
include(cmake/vcpkg.cmake)
if(ORC_BUILD_VCPKG OR ORC_DOWNLOADS_ONLY)
vcpkg_install(
${ONLY_DOWNLOADS}
PATH ${ORC_VCPKG_ROOT}
PACKAGES ${_PACKAGES}
ARCH ${TARGET_ARCH}
USE_STATIC_CRT ${ORC_USE_STATIC_CRT}
OVERLAY_TRIPLETS ${OVERLAY_TRIPLETS}
)
endif()
endif()
if(ORC_DOWNLOADS_ONLY)
return()
endif()
# Must be set AFTER 'VCPKG_TARGET_TRIPLET' is defined
project(dfir-orc LANGUAGES C CXX)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
# Workaround for https://github.com/Microsoft/vcpkg/issues/5621
set(CMAKE_MAP_IMPORTED_CONFIG_MINSIZEREL Release)
set(CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO Release)
if(NOT ORC_ROOT_VIRTUAL_FOLDER)
set(ORC_ROOT_VIRTUAL_FOLDER "" CACHE STRING "Root virtual folder name")
else()
set(ORC_ROOT_VIRTUAL_FOLDER "${ORC_ROOT_VIRTUAL_FOLDER}/")
endif()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
add_subdirectory(src)
add_subdirectory(tests)
add_subdirectory(tools)