-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathCMakeLists.txt
116 lines (90 loc) · 3.73 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
116
# Name: C++ threading library
# Creation date: lundi 24 septembre 2018, 10:39:35 (UTC+0200)
# Description: C++ threading library that mimics the C++11 standard implementation.
#
cmake_minimum_required(VERSION 3.11)
project(
cpp-pthread
VERSION 1.10.0
DESCRIPTION "Simple C++ wrapper of the standard POSIX pthread C library.")
if (CMAKE_BUILD_TYPE MATCHES Release)
if (GIT_LOG)
set(CPP_PTHREAD_VERSION "${PROJECT_VERSION} - ${GIT_LOG}")
else ()
set(CPP_PTHREAD_VERSION "${PROJECT_VERSION}")
endif ()
else ()
if (GIT_LOG)
set(CPP_PTHREAD_VERSION "${PROJECT_VERSION}-${GIT_LOG}-SNAPSHOT")
else ()
set(CPP_PTHREAD_VERSION "${PROJECT_VERSION}-SNAPSHOT")
endif ()
endif ()
option(BUILD_TESTS "enable/disable tests (default is enabled)" ON)
option(DEBUG "Set macro DEBUG")
if (DEBUG)
message(STATUS "Setting DEBUG macro...")
add_definitions(-DDEBUG=1)
endif ()
find_package(Coverage PATHS cmake)
find_package(GTestExt PATHS cmake)
# main targets --------------------------------------------------
#
add_definitions(-DCPP_PTHREAD_VERSION="${CPP_PTHREAD_VERSION}")
# This part MUST be executed before the loading of the CMake package. As we are using the CPP-PTHREAD_VERSION variable in the sonar properties file,
# we need to reun this after the setting of the version variable.
set(SONAR_PROPERTIES_FILE ${CMAKE_CURRENT_BINARY_DIR}/sonar-project.properties)
message(STATUS "Generating SONAR properties file ${SONAR_PROPERTIES_FILE}")
configure_file(${CMAKE_CURRENT_LIST_DIR}/sonar-project.properties.in ${SONAR_PROPERTIES_FILE})
find_package(SonarCloud PATHS cmake)
configure_file(src/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/config.h)
# project's public headers
include_directories(include src)
set(PTHREAD_SOURCE_CODE
src/config.h
src/condition_variable.cpp
src/exceptions.cpp
src/pthread.cpp
src/read_write_lock.cpp
src/thread.cpp
src/mutex.cpp
)
set(CMAKE_CXX_STANDARD 11)
add_library(cpp-pthread-static STATIC ${PTHREAD_SOURCE_CODE})
target_link_libraries(cpp-pthread-static pthread)
set_target_properties(cpp-pthread-static PROPERTIES OUTPUT_NAME cpp-pthread)
add_library(cpp-pthread-shared SHARED ${PTHREAD_SOURCE_CODE})
target_link_libraries(cpp-pthread-shared pthread)
set_target_properties(cpp-pthread-shared PROPERTIES OUTPUT_NAME cpp-pthread)
# Testing -------------------------------------------------------
#
if (GTestExt_FOUND AND BUILD_TESTS)
enable_testing()
message(STATUS "Adding project's unit tests (in ./tests)...")
add_subdirectory(tests)
endif ()
# doxygen -------------------------------------------------------
#
find_package(Doxygen REQUIRED dot OPTIONAL_COMPONENTS mscgen dia)
if (Doxygen_FOUND)
set(DOXYGEN_PROJECT_NUMBER ${CPP_PTHREAD_VERSION})
set(DOXYGEN_EXAMPLE_PATH tests)
set(DOXYGEN_EXTRACT_ALL yes)
set(DOXYGEN_PROJECT_BRIEF ${PROJECT_DESCRIPTION})
set(DOXYGEN_USE_MDFILE_AS_MAINPAGE "${CMAKE_SOURCE_DIR}/README.md")
doxygen_add_docs(doxygen README.md src include COMMENT "generate on-line documentation")
endif ()
# install -------------------------------------------------------
#
install(TARGETS cpp-pthread-static cpp-pthread-shared DESTINATION lib)
install(DIRECTORY include DESTINATION include COMPONENT Devel)
install(DIRECTORY ${PROJECT_BINARY_DIR}/html/ DESTINATION doc/cpp-pthread COMPONENT Documentation)
# CPACK ---------------------------------------------------------
#
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME})
set(CPACK_PACKAGE_RELEASE 1)
set(CPACK_PACKAGE_CONTACT "Herbert Koelman")
set(CPACK_PACKAGE_VENDOR "Urbix Software")
set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
include(CPack)