-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
77 lines (57 loc) · 2.08 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
cmake_minimum_required(VERSION 3.13.0)
# Clang
set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++)
# Start
project(libpiper)
# Version
set(VERSION_MAJOR "0")
set(VERSION_MINOR "1")
set(VERSION_PATCH "0")
# Warnings
add_compile_options(-Wall -Wextra -Werror -Wpointer-arith -Wshadow -Wnull-dereference)
add_link_options(-Wl,--no-undefined)
add_definitions(-D_GNU_SOURCE)
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 11)
# Main
add_library(piper SHARED src/common.c src/client.c src/server.c)
target_include_directories(piper PUBLIC include)
target_compile_definitions(piper PRIVATE -DPIPER_INTERNAL)
set_target_properties(piper PROPERTIES SOVERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
# Install
include(GNUInstallDirs)
install(TARGETS piper DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT "main")
install(DIRECTORY include/ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" COMPONENT "dev")
# CPack
set(CPACK_PACKAGE_NAME "libpiper")
set(CPACK_PACKAGE_VENDOR "TheBrokenRail")
set(CPACK_PACKAGE_VERSION_MAJOR "${VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${VERSION_PATCH}")
set(CPACK_PACKAGE_DESCRIPTION "Simple C Library Implementing Piper")
set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/RandomSoup/libpiper.git")
set(CPACK_PACKAGE_CONTACT "[email protected]")
set(CPACK_COMPONENT_DEV_DEPENDS "main")
set(CPACK_VERBATIM_VARIABLES TRUE)
set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_PACKAGE_NAME "libpiper")
set(CPACK_DEBIAN_MAIN_PACKAGE_NAME "libpiper")
set(CPACK_DEBIAN_DEV_PACKAGE_NAME "libpiper-dev")
set(CPACK_DEB_COMPONENT_INSTALL TRUE)
set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
set(CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS TRUE)
set(CPACK_DEBIAN_PACKAGE_SECTION "devel")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS TRUE)
set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS TRUE)
include(CPack)
# Examples
add_subdirectory(examples)
# Testing
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
option(BUILD_TESTING "Build Testing Code" TRUE)
if(BUILD_TESTING)
enable_testing()
add_subdirectory(tests)
endif()
endif()