1 |
cmake_minimum_required(VERSION 3.10) |
2 |
|
3 |
project(liblscp |
4 |
VERSION 0.9.3 |
5 |
DESCRIPTION "LinuxSampler Control Protocol API library" |
6 |
LANGUAGES C) |
7 |
|
8 |
set (CONFIG_VERSION ${PROJECT_VERSION}) |
9 |
execute_process ( |
10 |
COMMAND git describe --tags --dirty --abbrev=6 |
11 |
OUTPUT_VARIABLE GIT_DESCRIBE_OUTPUT |
12 |
RESULT_VARIABLE GIT_DESCRIBE_RESULT |
13 |
OUTPUT_STRIP_TRAILING_WHITESPACE) |
14 |
if (GIT_DESCRIBE_RESULT EQUAL 0) |
15 |
set (VERSION "${GIT_DESCRIBE_OUTPUT}") |
16 |
string (REGEX REPLACE "^[^0-9]+" "" VERSION "${VERSION}") |
17 |
string (REGEX REPLACE "-g" "git." VERSION "${VERSION}") |
18 |
string (REGEX REPLACE "[_|-]+" "." VERSION "${VERSION}") |
19 |
execute_process ( |
20 |
COMMAND git rev-parse --abbrev-ref HEAD |
21 |
OUTPUT_VARIABLE GIT_REVPARSE_OUTPUT |
22 |
RESULT_VARIABLE GIT_REVPARSE_RESULT |
23 |
OUTPUT_STRIP_TRAILING_WHITESPACE) |
24 |
if (GIT_REVPARSE_RESULT EQUAL 0 AND NOT GIT_REVPARSE_OUTPUT STREQUAL "master") |
25 |
set (VERSION "${VERSION} [${GIT_REVPARSE_OUTPUT}]") |
26 |
endif () |
27 |
else () |
28 |
set (VERSION "${PROJECT_VERSION}") |
29 |
endif () |
30 |
|
31 |
set (PACKAGE_NAME "liblscp") |
32 |
set (PACKAGE_VERSION "${VERSION}") |
33 |
set (PACKAGE_BUGREPORT "rncbc@rncbc.org") |
34 |
set (PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") |
35 |
set (PACKAGE_TARNAME "liblscp") |
36 |
|
37 |
set (ac_version "${PROJECT_VERSION}") |
38 |
set (ac_prefix "${CMAKE_INSTALL_PREFIX}") |
39 |
|
40 |
#------------------------------------------------------------------------------------ |
41 |
# Rules for library version information: |
42 |
# |
43 |
# 1. Start with version information of `0:0:0' for each libtool library. |
44 |
# 2. Update the version information only immediately before a public release of |
45 |
# your software. More frequent updates are unnecessary, and only guarantee |
46 |
# that the current interface number gets larger faster. |
47 |
# 3. If the library source code has changed at all since the last update, then |
48 |
# increment revision (`c:r:a' becomes `c:r+1:a'). |
49 |
# 4. If any interfaces have been added, removed, or changed since the last update, |
50 |
# increment current, and set revision to 0. |
51 |
# 5. If any interfaces have been added since the last public release, then increment |
52 |
# age. |
53 |
# 6. If any interfaces have been removed since the last public release, then set age |
54 |
# to 0. |
55 |
# |
56 |
#set (BUILD_SHARED_LIBS ON) |
57 |
|
58 |
set (SHARED_VERSION_CURRENT 6) |
59 |
set (SHARED_VERSION_AGE 0) |
60 |
set (SHARED_VERSION_REVISION 4) |
61 |
set (SHARED_VERSION_INFO "${SHARED_VERSION_CURRENT}.${SHARED_VERSION_AGE}.${SHARED_VERSION_REVISION}") |
62 |
|
63 |
if (CMAKE_BUILD_TYPE) |
64 |
set (CONFIG_BUILD_TYPE ${CMAKE_BUILD_TYPE}) |
65 |
else () |
66 |
set (CONFIG_BUILD_TYPE "release") |
67 |
endif () |
68 |
|
69 |
set (CONFIG_DEBUG 0) |
70 |
if (CONFIG_BUILD_TYPE MATCHES "debug") |
71 |
set (CONFIG_DEBUG 1) |
72 |
endif () |
73 |
|
74 |
set (CONFIG_PREFIX "${CMAKE_INSTALL_PREFIX}") |
75 |
|
76 |
include (GNUInstallDirs) |
77 |
set (CONFIG_BINDIR "${CONFIG_PREFIX}/${CMAKE_INSTALL_BINDIR}") |
78 |
set (CONFIG_LIBDIR "${CONFIG_PREFIX}/${CMAKE_INSTALL_LIBDIR}") |
79 |
set (CONFIG_DATADIR "${CONFIG_PREFIX}/${CMAKE_INSTALL_DATADIR}") |
80 |
set (CONFIG_INCLUDEDIR "${CONFIG_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}") |
81 |
|
82 |
# |
83 |
# No special build options... |
84 |
# |
85 |
|
86 |
# Fix for new CMAKE_REQUIRED_LIBRARIES policy. |
87 |
if (POLICY CMP0075) |
88 |
cmake_policy (SET CMP0075 NEW) |
89 |
endif () |
90 |
|
91 |
include (CheckIncludeFiles) |
92 |
include (CheckFunctionExists) |
93 |
|
94 |
# Checks for standard header files. |
95 |
if (UNIX AND NOT APPLE) |
96 |
check_include_files ("stdlib.h;string.h;netdb.h;arpa/inet.h;netinet/tcp.h;netinet/in.h;sys/socket.h;unistd.h" HAVE_HEADERS_H) |
97 |
if (NOT HAVE_HEADERS_H) |
98 |
message (FATAL_ERROR "*** Standard headers not found.") |
99 |
endif () |
100 |
endif () |
101 |
|
102 |
# Checks for standard functions. |
103 |
if (UNIX AND NOT APPLE) |
104 |
set (FUNCS "strdup;strtok_r;memset;memmove;socket;connect;bind;listen;setsockopt;getsockopt;getsockname;gethostbyname") |
105 |
foreach (FUNC ${FUNCS}) |
106 |
check_function_exists (${FUNC} HAVE_${FUNC}_C) |
107 |
if (NOT HAVE_${FUNC}_C) |
108 |
message (FATAL_ERROR "*** Standard functions not found.") |
109 |
endif () |
110 |
endforeach () |
111 |
endif () |
112 |
|
113 |
# |
114 |
# No additional packages or libraries... |
115 |
# |
116 |
|
117 |
add_subdirectory (src) |
118 |
add_subdirectory (doc) |
119 |
add_subdirectory (examples) |
120 |
|
121 |
configure_file (liblscp.spec.in liblscp.spec IMMEDIATE @ONLY) |
122 |
|
123 |
configure_file (lscp.pc.in lscp.pc IMMEDIATE @ONLY) |
124 |
|
125 |
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/lscp.pc |
126 |
DESTINATION ${CONFIG_LIBDIR}/pkgconfig) |
127 |
|