forked from estkme-group/lpac
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
117 lines (102 loc) · 3.77 KB
/
CMakeLists.txt
File metadata and controls
117 lines (102 loc) · 3.77 KB
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
cmake_minimum_required (VERSION 3.23)
project (lpac
VERSION 2.3.0
HOMEPAGE_URL "https://github.com/estkme-group/lpac"
DESCRIPTION "C-based eUICC LPA."
LANGUAGES C)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
include(CMakeDependentOption)
option(USE_SYSTEM_DEPS "Use system-wide installed dependencies" OFF)
option(STANDALONE_MODE "All things in a relocatable directory" OFF)
option(LPAC_DYNAMIC_LIBEUICC "Build and install libeuicc as a dynamic library" ON)
set(LPAC_CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
list(APPEND CMAKE_MODULE_PATH ${LPAC_CMAKE_MODULE_PATH})
if(NOT PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
# Git auto-ignore out-of-source build directory
file(GENERATE OUTPUT .gitignore CONTENT "*")
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# add_compile_options(-Wall -Wextra -Wpedantic)
if (NOT DEFINED CMAKE_INTERPROCEDURAL_OPTIMIZATION)
message(CHECK_START "Detecting LTO")
include(CheckIPOSupported)
check_ipo_supported(RESULT CMAKE_INTERPROCEDURAL_OPTIMIZATION OUTPUT LTO_ERROR)
if (LTO_ERROR)
message(CHECK_FAIL "Not supported: ${LTO_ERROR}")
else ()
message(CHECK_PASS "Supported")
endif ()
endif ()
if (NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE)
message(CHECK_START "Detecting PIE/PIC")
include(CheckPIESupported)
check_pie_supported(OUTPUT_VARIABLE PIC_ERROR)
set(CMAKE_POSITION_INDEPENDENT_CODE ${CMAKE_C_LINK_PIE_SUPPORTED})
if (PIC_ERROR)
message(CHECK_FAIL "Not supported: ${PIC_ERROR}")
else ()
message(CHECK_PASS "Supported")
endif ()
endif ()
if (APPLE AND NOT DEFINED CMAKE_OSX_ARCHITECTURES)
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64")
endif ()
if(APPLE)
set(RPATH_BINARY_PATH "@loader_path")
else()
set(RPATH_BINARY_PATH "$ORIGIN")
endif()
if(NOT CMAKE_INSTALL_RPATH)
if (STANDALONE_MODE)
cmake_policy(SET CMP0177 NEW)
# SHALL use semicolon-separated list so CMake can convert to platform separator.
set(CMAKE_INSTALL_RPATH "${RPATH_BINARY_PATH};${RPATH_BINARY_PATH}/lib")
set(CMAKE_INSTALL_PREFIX "")
set(CMAKE_INSTALL_BINDIR "executables")
set(CMAKE_INSTALL_LIBDIR "executables/lib")
include(GNUInstallDirs)
set(DRIVER_INSTALL_PATH ${CMAKE_INSTALL_FULL_BINDIR}/driver)
elseif (UNIX)
include(GNUInstallDirs)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}/lpac")
set(DRIVER_INSTALL_PATH "${CMAKE_INSTALL_FULL_LIBDIR}/lpac/driver")
endif()
endif()
if(WIN32)
add_subdirectory(dlfcn-win32)
set(DL_LIBRARY dlfcn-win32)
else()
set(DL_LIBRARY dl)
endif()
if (USE_SYSTEM_DEPS)
find_package(cJSON REQUIRED)
elseif (NOT NO_NETWORK)
set(CJSON_OVERRIDE_BUILD_SHARED_LIBS ON)
set(CJSON_BUILD_SHARED_LIBS OFF)
set(ENABLE_CJSON_TEST OFF)
set(ENABLE_CUSTOM_COMPILER_FLAGS OFF)
include(FetchContent)
FetchContent_Declare(
cjson
# FIXME: change back to DaveGamble/cJSON if upstream fix it
# https://github.com/DaveGamble/cJSON/pull/949
# https://github.com/DaveGamble/cJSON/pull/955
GIT_REPOSITORY https://github.com/CoelacanthusHex/cJSON
GIT_TAG 4818f043bda624b5738384eae3a0189b2bd1f5e1
GIT_PROGRESS ON
SOURCE_DIR cjson
)
FetchContent_MakeAvailable(cjson)
set(CJSON_LIBRARY cjson)
# Force cJSON dynamically link CRT although it's statuc librgary.
set_property(TARGET cjson PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
else ()
message(FATAL_ERROR "cJSON is required. Either set USE_SYSTEM_DEPS to ON or enable network to download it.")
endif ()
add_subdirectory(cjson-ext)
add_subdirectory(euicc)
add_subdirectory(utils)
add_subdirectory(driver)
add_subdirectory(src)