-
Notifications
You must be signed in to change notification settings - Fork 21
/
CMakeLists.txt
70 lines (52 loc) · 2.33 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
cmake_minimum_required(VERSION 2.8)
project(lfqueue)
set(PROJNAME lfqueue)
IF (NOT DEFINED CMAKE_INSTALL_INCLUDEDIR)
SET(CMAKE_INSTALL_INCLUDEDIR /usr/local/include)
ENDIF(NOT DEFINED CMAKE_INSTALL_INCLUDEDIR)
file(GLOB_RECURSE sources lfqueue.c lfqueue.h)
file(GLOB_RECURSE sources_test test.cpp)
file(GLOB_RECURSE example_test lfqueue.c lfqueue.h example.c)
enable_testing()
add_executable(lfqueue-example ${example_test})
target_link_libraries(lfqueue-example PUBLIC pthread)
include_directories(src /usr/local/include)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -Wall -Wstrict-prototypes -Wmissing-prototypes")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-declarations -Wshadow -Wpointer-arith -Wcast-qual")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wsign-compare -std=c11 -pedantic")
###############################################################################
## packaging ##################################################################
###############################################################################
add_library(${PROJNAME}.static STATIC ${sources})
target_link_libraries(${PROJNAME}.static)
set_target_properties(${PROJNAME}.static PROPERTIES OUTPUT_NAME ${PROJNAME})
add_library(${PROJNAME} SHARED ${sources})
target_link_libraries(${PROJNAME})
add_test (NAME lfqueue_test COMMAND lfqueue-example)
# link_directories(/usr/local/lib /usr/lib)
## For .a library
install(TARGETS ${PROJNAME}.static EXPORT ${PROJNAME}
ARCHIVE DESTINATION lib${LIB_SUFFIX}
LIBRARY DESTINATION lib${LIB_SUFFIX}
# RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
## For .so library
install(TARGETS ${PROJNAME} EXPORT ${PROJNAME}
ARCHIVE DESTINATION lib${LIB_SUFFIX}
LIBRARY DESTINATION lib${LIB_SUFFIX}
# RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(FILES lfqueue.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lfsaq)
install(CODE "execute_process(COMMAND ldconfig)")
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
set(CPACK_PACKAGE_NAME "lfqueue")
set(CPACK_PACKAGE_VERSION "1.0.0")
# we don't want to split our program up into several things
set(CPACK_MONOLITHIC_INSTALL 1)
# This must be last
include(CPack)