-
Notifications
You must be signed in to change notification settings - Fork 11
/
CMakeLists.txt
71 lines (60 loc) · 2 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
cmake_minimum_required(VERSION 3.10)
project(hexdumper)
set(CMAKE_CXX_STANDARD 17)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_find")
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(LINUX TRUE)
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(DARWIN TRUE)
elseif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
set(FREEBSD TRUE)
endif()
# checking if we are called in the correct way:
# with a -B argument. and without a cache file in the source directory.
if (CMAKE_CACHEFILE_DIR STREQUAL "${CMAKE_SOURCE_DIR}")
message(FATAL_ERROR "\nUnexpected CMakeCache.txt file in the source directory. Please remove it.")
return()
endif()
if (EXISTS ${CMAKE_BINARY_DIR}/CMakeLists.txt)
message(FATAL_ERROR "\nRun cmake with an explicit -B buildpath")
return()
endif()
if(MSVC)
# /MP = multithreaded build
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
# /utf-8 = utf8 source and execution
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8")
endif()
if (WIN32)
add_definitions(-DNOMINMAX -DNOGDI)
endif()
find_package(cpputils REQUIRED)
if (NOT WIN32)
find_package(openssl REQUIRED)
endif()
add_executable(dump dump.cpp dumputils/bigascdump.cpp dumputils/bighexdump.cpp)
target_link_libraries(dump cpputils)
target_include_directories(dump PUBLIC dumputils)
if (WIN32)
target_compile_definitions(dump PUBLIC -D_USE_WINCRYPTAPI)
else()
target_compile_definitions(dump PUBLIC -D_USE_OPENSSL)
target_link_libraries(dump OpenSSL::Crypto)
endif()
if (NOT WIN32)
# NOTE: until I add windows support to cpputils/mmem.h these will not build.
list(APPEND Dump2Src dump2.cpp)
if (DARWIN)
list(APPEND Dump2Src machmemory.cpp)
endif()
add_executable(dump2 ${Dump2Src})
target_link_libraries(dump2 cpputils)
if (DARWIN)
find_library(SecurityFramework Security)
target_link_libraries(dump2 ${SecurityFramework})
endif()
add_executable(mmdump mmdump.cpp)
target_link_libraries(mmdump cpputils)
add_executable(mmedit mmedit.cpp)
target_link_libraries(mmedit cpputils)
endif()