forked from zhanglw-dev/queue-c
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
115 lines (96 loc) · 3.04 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
project(queue-c LANGUAGES C)
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE)
message(STATUS "Build type set to ${CMAKE_BUILD_TYPE}")
#add_compile_options(-D__USE_GNU -std=gnu99) #for some centos build failed
include(GNUInstallDirs)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
# Offer the user the choice of overriding the installation directories
set(INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR} CACHE PATH "Installation directory for libraries")
set(INSTALL_BINDIR ${CMAKE_INSTALL_BINDIR} CACHE PATH "Installation directory for executables")
set(INSTALL_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE PATH "Installation directory for header")
# Report to user
foreach(p LIB BIN INCLUDE)
file(TO_NATIVE_PATH ${CMAKE_INSTALL_PREFIX}/${INSTALL_${p}DIR} _path )
message(STATUS "Installing ${p} components to ${_path}")
unset(_path)
endforeach()
add_subdirectory(src/qc_rt)
add_subdirectory(src/qc_mq)
add_subdirectory(src/qc_qsys)
add_subdirectory(src/qc_net)
add_subdirectory(src/qc_psist)
add_subdirectory(src/qc_shq)
add_subdirectory(demo)
add_subdirectory(test)
add_library(qc
STATIC
$<TARGET_OBJECTS:qc_rt>
$<TARGET_OBJECTS:qc_mq>
$<TARGET_OBJECTS:qc_qsys>
$<TARGET_OBJECTS:qc_net>
$<TARGET_OBJECTS:qc_shq>
$<TARGET_OBJECTS:qc_psist>
)
# Prepare RPATH
file(RELATIVE_PATH _rel ${CMAKE_INSTALL_PREFIX}/${INSTALL_BINDIR} ${CMAKE_INSTALL_PREFIX})
if(APPLE)
set(_rpath "@loader_path/${_rel}")
else()
set(_rpath "\$ORIGIN/${_rel}")
endif()
file(TO_NATIVE_PATH "${_rpath}/${INSTALL_LIBDIR}" qc_RPATH)
set_target_properties(qc
PROPERTIES
MACOSX_RPATH ON
SKIP_BUILD_RPATH OFF
BUILD_WITH_INSTALL_RPATH OFF
INSTALL_RPATH "${qc_RPATH}"
INSTALL_RPATH_USE_LINK_PATH ON
)
list(APPEND QC_API_HEADERS
src/qc_rt/qc_prelude.h
src/qc_rt/qc_error.h
src/qc_rt/qc_file.h
src/qc_rt/qc_hash.h
src/qc_rt/qc_list.h
src/qc_rt/qc_log.h
src/qc_rt/qc_sem.h
src/qc_rt/qc_shm.h
src/qc_rt/qc_socket.h
src/qc_rt/qc_thread.h
src/qc_mq/qc_message.h
src/qc_mq/qc_queue.h
src/qc_qsys/qc_qsystem.h
src/qc_net/qc_server.h
src/qc_net/qc_client.h
src/qc_shq/qc_shq_mem.h
src/qc_shq/qc_shque.h
)
set_target_properties(qc
PROPERTIES
PUBLIC_HEADER "${QC_API_HEADERS}"
)
install(
TARGETS
qc
ARCHIVE
DESTINATION ${INSTALL_LIBDIR}
COMPONENT lib
RUNTIME
DESTINATION ${INSTALL_BINDIR}
COMPONENT bin
LIBRARY
DESTINATION ${INSTALL_LIBDIR}
COMPONENT lib
PUBLIC_HEADER
DESTINATION ${INSTALL_INCLUDEDIR}/qc
COMPONENT dev
)
enable_testing()
add_test(
NAME qctest
COMMAND $<TARGET_FILE:qctest>
)