-
Notifications
You must be signed in to change notification settings - Fork 27
/
CMakeLists.txt
executable file
·97 lines (80 loc) · 2.37 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
cmake_minimum_required(VERSION 3.12)
project(pkg_pfs_tool)
#
# Compiler settings.
#
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
if(NOT ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm64"))
add_compile_options(-masm=intel -march=native)
endif()
add_compile_options(-Wall -Wextra -Werror-implicit-function-declaration -Wno-unused-function -Wno-unused-label)
# just install libasan6 (or w/e) then flip this ON
set(ENABLE_ASAN OFF)
if(ENABLE_ASAN)
add_compile_options(-ggdb -O0)
set(ASAN_FLAGS -fsanitize=address)
add_compile_options(${ASAN_FLAGS})
add_link_options(${ASAN_FLAGS})
endif()
if(WIN32)
add_compile_definitions(WIN32 _WIN32)
add_compile_definitions(WIN32_LEAN_AND_MEAN)
add_compile_definitions(NOMINMAX)
endif()
if(UNIX OR MSYS)
add_compile_definitions(_GNU_SOURCE)
endif()
add_compile_definitions(
$<$<CONFIG:DEBUG>:_DEBUG>
$<$<CONFIG:RELEASE>:NDEBUG>
)
#
# Third-party dependendices.
#
string(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
set(THIRDPARTY_ROOT_DIR "${CMAKE_SOURCE_DIR}/thirdparty")
set(THIRDPARTY_INCLUDE_DIR "${THIRDPARTY_ROOT_DIR}/include")
if(MINGW)
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
set(THIRDPARTY_LIB_DIR "${THIRDPARTY_ROOT_DIR}/lib/win64")
else()
set(THIRDPARTY_LIB_DIR "${THIRDPARTY_ROOT_DIR}/lib/win32")
endif()
elseif(APPLE)
if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm64")
set(THIRDPARTY_LIB_DIR "${THIRDPARTY_ROOT_DIR}/lib/darwin-arm64")
else()
set(THIRDPARTY_LIB_DIR "${THIRDPARTY_ROOT_DIR}/lib/darwin-x86")
endif()
elseif(UNIX)
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
set(THIRDPARTY_LIB_DIR "${THIRDPARTY_ROOT_DIR}/lib/linux64")
else()
set(THIRDPARTY_LIB_DIR "${THIRDPARTY_ROOT_DIR}/lib/linux32")
endif()
endif()
if(MINGW)
# hack to force static zlib (but it doesn't mess anything else up...)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
list(APPEND LIBS ucrt)
endif()
find_package(ZLIB REQUIRED)
include_directories(${ZLIB_INCLUDE_DIRS})
list(APPEND LIBS ${ZLIB_LIBRARIES})
find_package(MBEDTLS 2.24.0 REQUIRED)
include_directories(${MBEDTLS_INCLUDE_DIRS})
list(APPEND LIBS ${MBEDTLS_LIBRARIES})
find_package(UTHASH REQUIRED)
include_directories(${UTHASH_INCLUDE_DIRS})
#
# Project settings.
#
file(GLOB SRCS "src/*.c")
if(MINGW)
file(GLOB MINGW_SRCS "src/mingw/*.c")
list(APPEND SRCS ${MINGW_SRCS})
endif()
include_directories(src)
add_executable(pkg_pfs_tool ${SRCS})
target_link_libraries(pkg_pfs_tool ${LIBS})