Repository navigation
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
109 lines (89 loc) · 2.72 KB
/
Copy pathCMakeLists.txt
File metadata and controls
109 lines (89 loc) · 2.72 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
cmake_minimum_required(VERSION 3.16)
project(EmexFoundation
VERSION 1.0.0
LANGUAGES C
)
find_package(Threads REQUIRED)
option(EMEXFOUNDATION_STATIC "EmexFoundation will be linked as a static library" OFF)
if(EMEXFOUNDATION_STATIC)
set(LIB_TYPE STATIC)
else()
set(LIB_TYPE SHARED)
endif()
add_library(EmexFoundation ${LIB_TYPE}
src/CrossSupport/MFD.c
src/EFRuntime/EFBase.c
src/EFRuntime/EFAllocator.c
src/EFRuntime/EFClass.c
src/EFRuntime/EFObject.c
src/EFNumber.c
src/EFString.c
src/EFArray.c
src/EFData.c
src/EFFileHandle.c
src/EFProcess.c
src/EFURL.c
src/EFFile.c
src/EFBitWalker.c
src/EFUUID.c
src/EFMapping.c
src/EFMallocBlock.c
src/EFFileManager.c
src/EFDictionary.c
)
target_include_directories(EmexFoundation
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_compile_features(EmexFoundation PUBLIC c_std_23)
set_target_properties(EmexFoundation PROPERTIES
C_EXTENSIONS ON
)
if (MSVC)
# Fuck MSVC nobody likes you
message(FATAL_ERROR "MSVC is not supported. Switch to Linux moron, microslop sheep!")
else()
# Setting up compiler flags
set(_EF_WARN_FLAGS -Wall -Wextra -Wpedantic -Wno-unused-parameter -Wno-gnu-conditional-omitted-operand)
set(_EF_OPT_FLAGS -fPIC)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
list(APPEND _EF_OPT_FLAGS -O0 -g)
else()
list(APPEND _EF_OPT_FLAGS -O3 -fomit-frame-pointer -fstrict-aliasing -funroll-loops)
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
list(APPEND _EF_OPT_FLAGS -fgraphite-identity -floop-nest-optimize -fipa-pta)
elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
list(APPEND _EF_OPT_FLAGS -fvectorize -fslp-vectorize -fvisibility=hidden -fvisibility-inlines-hidden)
endif()
if(APPLE)
target_link_options(EmexFoundation PRIVATE
"LINKER:-dead_strip"
)
else()
target_link_options(EmexFoundation PRIVATE
"LINKER:--exclude-libs,ALL"
"LINKER:--gc-sections"
"LINKER:-Bsymbolic"
)
endif()
endif()
target_compile_definitions(EmexFoundation PRIVATE $<$<CONFIG:Debug>:DEBUG>)
target_compile_options(EmexFoundation PRIVATE ${_EF_WARN_FLAGS} ${_EF_OPT_FLAGS})
endif()
target_link_libraries(EmexFoundation
PRIVATE
Threads::Threads
)
install(TARGETS EmexFoundation
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
DESTINATION include
FILES_MATCHING
PATTERN "*.h"
)
set_target_properties(EmexFoundation PROPERTIES
INSTALL_NAME_DIR "/usr/local/lib"
)