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