forked from aziomq/aziomq
-
Notifications
You must be signed in to change notification settings - Fork 108
/
CMakeLists.txt
79 lines (61 loc) · 2.8 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
cmake_minimum_required(VERSION 3.16.3...3.25)
# -- v3.16.3 is the default version in the current ubuntu lts release
project(azmq VERSION 1.1.0 LANGUAGES CXX)
if (PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(CMAKE_MASTER_PROJECT YES)
endif ()
# -- options
option(AZMQ_BUILD_TESTS "run unit tests" ${CMAKE_MASTER_PROJECT})
option(BUILD_SHARED_LIBS "use the libzmq static or shared" yes)
option(AZMQ_DEVELOPER "Add verbose warning for developers " ${CMAKE_MASTER_PROJECT})
option(AZMQ_BUILD_DOC "Add documentation example" ${CMAKE_MASTER_PROJECT})
# -- config settings --
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# --- dependencies --
find_package(
Boost 1.68
COMPONENTS system
date_time
thread
chrono
random
REQUIRED)
include(FindAzmqLibzmq.cmake)
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package(Threads REQUIRED)
# --- create library --
add_library(${PROJECT_NAME} INTERFACE)
add_library(Azmq::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
target_link_libraries(${PROJECT_NAME} INTERFACE Azmq::libzmq Boost::boost ${CMAKE_THREAD_LIBS_INIT})
target_include_directories(${PROJECT_NAME} INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
"$<INSTALL_INTERFACE:include>")
if (AZMQ_DEVELOPER)
include(cmake/CompilerWarnings.cmake)
add_more_warnings_to(${PROJECT_NAME})
endif ()
if (CMAKE_MASTER_PROJECT AND NOT CMAKE_SKIP_INSTALL_RULES)
include(AzmqCPack.cmake)
include(CMakePackageConfigHelpers)
# generate the version file for the config file
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion)
# install the public headers
install(DIRECTORY azmq DESTINATION include)
install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Targets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib)
configure_file(${PROJECT_NAME}Config.cmake "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" COPYONLY)
set(ConfigPackageLocation lib/cmake/${PROJECT_NAME})
install(EXPORT ${PROJECT_NAME}Targets NAMESPACE Azmq:: DESTINATION ${ConfigPackageLocation})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake DESTINATION ${ConfigPackageLocation})
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/FindAzmqLibzmq.cmake" DESTINATION ${ConfigPackageLocation})
endif ()
if (AZMQ_BUILD_TESTS)
enable_testing()
message(STATUS "Building Tests. Be sure to check out test/constexpr_tests for constexpr testing")
add_subdirectory(test)
endif ()
if (AZMQ_BUILD_DOC)
add_subdirectory(doc)
endif()