-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
83 lines (70 loc) · 1.92 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
cmake_minimum_required(VERSION 3.13.0)
project(spr
LANGUAGES C
DESCRIPTION "Simplified Portable Runtime Library (SPR)"
)
if (BUILD_SHARED_LIBS)
add_library(${PROJECT_NAME} SHARED)
else()
add_library(${PROJECT_NAME} STATIC)
endif()
include(cmake/spr_options.cmake)
include(cmake/spr_config.cmake)
target_include_directories(${PROJECT_NAME}
PRIVATE
include
${PROJECT_BINARY_DIR}
)
target_sources(${PROJECT_NAME}
PRIVATE
lib/spr_array.c
lib/spr_cpuinfo.c
lib/spr_dso.c
lib/spr_errno.c
lib/spr_filesys.c
lib/spr_list.c
lib/spr_string.c
lib/spr_time.c
lib/spr_version.c
lib/memory/spr_memory.c
lib/memory/spr_pool.c
lib/network/spr_sockaddr.c
lib/network/spr_socket.c
lib/network/spr_sockopt.c
lib/thread/spr_mutex.c
lib/thread/spr_semaphore.c
lib/thread/spr_thread.c
)
target_compile_options(${PROJECT_NAME}
PRIVATE
-Wall
-Wextra
-Wuninitialized
)
target_compile_features(${PROJECT_NAME} PRIVATE c_std_99)
target_compile_definitions(${PROJECT_NAME}
PRIVATE
SPR_SYSTEM_NAME="${CMAKE_SYSTEM_NAME}"
)
if (NOT CMAKE_BUILD_TYPE)
set (build_type release)
else()
string(TOLOWER ${CMAKE_BUILD_TYPE} build_type)
endif()
if (build_type STREQUAL debug)
target_compile_options(${PROJECT_NAME} PRIVATE -g3 -O0 -ggdb3)
elseif (build_type STREQUAL release)
target_compile_options(${PROJECT_NAME} PRIVATE -g0 -O3)
endif()
target_link_libraries(${PROJECT_NAME}
${CMAKE_REQUIRED_LIBRARIES}
)
if (SPR_POSIX)
target_link_libraries(${PROJECT_NAME} pthread)
target_link_libraries(${PROJECT_NAME} ${CMAKE_DL_LIBS})
elseif(SPR_WIN32)
target_link_libraries(${PROJECT_NAME} ws2_32)
endif()
install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include/${PROJECT_NAME})
install(FILES build/spr_config.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/${PROJECT_NAME})