-
Notifications
You must be signed in to change notification settings - Fork 9
/
CMakeLists.txt
75 lines (53 loc) · 2.46 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
cmake_minimum_required(VERSION 2.8)
project(athpool)
set(PROJNAME athpool)
IF (WIN32 OR MSVC OR MSYS OR MINGW OR APPLE)
message( FATAL_ERROR "for windows build, please open with visual studio project")
endif()
MESSAGE(STATUS "Unix Build ... ")
IF (NOT DEFINED CMAKE_INSTALL_INCLUDEDIR)
SET(CMAKE_INSTALL_INCLUDEDIR /usr/local/include)
ENDIF(NOT DEFINED CMAKE_INSTALL_INCLUDEDIR)
include_directories(/usr/local/include /usr/include lfqueue)
file(GLOB_RECURSE sources at_thpool.h at_thpool.c lfqueue/lfqueue.h lfqueue/lfqueue.c)
file(GLOB_RECURSE example_test ${sources} threadpool_example.c)
add_executable(example_threadpool ${example_test})
target_link_libraries(example_threadpool PUBLIC pthread)
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 -pedantic")
###############################################################################
## packaging ##################################################################
###############################################################################
add_library(${PROJNAME}.static STATIC ${sources})
target_link_libraries(${PROJNAME}.static pthread)
set_target_properties(${PROJNAME}.static PROPERTIES OUTPUT_NAME ${PROJNAME})
add_library(${PROJNAME} SHARED ${sources})
target_link_libraries(${PROJNAME} pthread)
# 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 at_thpool.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
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 "at_thpool")
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)