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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
|
From e29952e7ceff64de6fc6f8db43e3b326481280be Mon Sep 17 00:00:00 2001
From: Ghislain MARY <ghislain.mary@belledonne-communications.com>
Date: Mon, 19 Jun 2023 16:56:50 +0200
Subject: [PATCH] Improve CMake package config and find_package scripts.
---
...29Config.cmake.in => BCG729Config.cmake.in | 46 ++++++++-----------
CMakeLists.txt | 43 +++++++++--------
build/CMakeLists.txt | 5 +-
src/CMakeLists.txt | 8 +---
4 files changed, 44 insertions(+), 58 deletions(-)
rename Bcg729Config.cmake.in => BCG729Config.cmake.in (51%)
--- a/Bcg729Config.cmake.in
+++ /dev/null
@@ -1,55 +0,0 @@
-############################################################################
-# Bcg729Config.cmake
-# Copyright (C) 2015-2023 Belledonne Communications, Grenoble France
-#
-############################################################################
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-############################################################################
-#
-# Config file for the bcg729 package.
-# It defines the following variables:
-#
-# BCG729_FOUND - system has bcg729
-# BCG729_INCLUDE_DIRS - the bcg729 include directory
-# BCG729_LIBRARIES - The libraries needed to use bcg729
-# BCG729_CPPFLAGS - The compilation flags needed to use bcg729
-
-@PACKAGE_INIT@
-
-include("${CMAKE_CURRENT_LIST_DIR}/Bcg729Targets.cmake")
-
-set(BCG729_TARGETNAME bcg729)
-if(@BUILD_SHARED_LIBS@)
- set(BCG729_LIBRARIES ${BCG729_TARGETNAME})
-else()
- get_target_property(BCG729_LIBRARIES ${BCG729_TARGETNAME} LOCATION)
- get_target_property(BCG729_LINK_LIBRARIES ${BCG729_TARGETNAME} INTERFACE_LINK_LIBRARIES)
- if(BCG729_LINK_LIBRARIES)
- list(APPEND BCG729_LIBRARIES ${BCG729_LINK_LIBRARIES})
- endif()
-endif()
-get_target_property(BCG729_INCLUDE_DIRS ${BCG729_TARGETNAME} INTERFACE_INCLUDE_DIRECTORIES)
-if (NOT BCG729_INCLUDE_DIRS)
- set (BCG729_INCLUDE_DIRS)
-endif()
-
-list(INSERT BCG729_INCLUDE_DIRS 0 "@CMAKE_INSTALL_FULL_INCLUDEDIR@")
-
-list(REMOVE_DUPLICATES BCG729_INCLUDE_DIRS)
-
-set(BCG729_CPPFLAGS @BCG729_CPPFLAGS@)
-set(BCG729_FOUND 1)
--- /dev/null
+++ b/BCG729Config.cmake.in
@@ -0,0 +1,47 @@
+############################################################################
+# BCG729Config.cmake
+# Copyright (C) 2015-2023 Belledonne Communications, Grenoble France
+#
+############################################################################
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+############################################################################
+#
+# Config file for the bcg729 package.
+#
+# Targets
+# ^^^^^^^
+#
+# The following targets are defined:
+# bcg729 - The bcg729 library target
+#
+#
+# Result variables
+# ^^^^^^^^^^^^^^^^
+#
+# This config file will set the following variables in your project:
+#
+# BCG729_FOUND - The bcg729 library has been found
+# BCG729_TARGET - The name of the CMake target for the bcg729 library
+
+
+@PACKAGE_INIT@
+
+include("${CMAKE_CURRENT_LIST_DIR}/BCG729Targets.cmake")
+
+set(BCG729_TARGET bcg729)
+
+check_required_components(BZRTP)
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -20,9 +20,9 @@
#
############################################################################
-cmake_minimum_required(VERSION 3.1)
+cmake_minimum_required(VERSION 3.22)
-project(bcg729 VERSION 1.1.1 LANGUAGES C)
+project(BCG729 VERSION 1.1.1 LANGUAGES C)
set(PACKAGE "${PROJECT_NAME}")
@@ -77,21 +77,30 @@ endif()
include(CMakePackageConfigHelpers)
-set(CONFIG_PACKAGE_LOCATION "${CMAKE_INSTALL_DATADIR}/Bcg729/cmake")
-write_basic_package_version_file(
- "${PROJECT_BINARY_DIR}/Bcg729ConfigVersion.cmake"
- VERSION ${PACKAGE_VERSION}
+set(CMAKE_MODULES_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake")
+configure_package_config_file("${PROJECT_NAME}Config.cmake.in" "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
+ INSTALL_DESTINATION "${CMAKE_MODULES_INSTALL_DIR}"
+ NO_SET_AND_CHECK_MACRO
+)
+write_basic_package_version_file("${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
+ VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
-export(EXPORT Bcg729Targets
- FILE "${PROJECT_BINARY_DIR}/Bcg729Targets.cmake"
+install(FILES
+ "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
+ "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
+ DESTINATION ${CMAKE_MODULES_INSTALL_DIR}
+)
+
+export(EXPORT ${PROJECT_NAME}Targets
+ FILE "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake"
)
-configure_package_config_file(Bcg729Config.cmake.in
- "${PROJECT_BINARY_DIR}/Bcg729Config.cmake"
- INSTALL_DESTINATION ${CONFIG_PACKAGE_LOCATION}
- NO_SET_AND_CHECK_MACRO
+install(EXPORT ${PROJECT_NAME}Targets
+ FILE "${PROJECT_NAME}Targets.cmake"
+ DESTINATION ${CMAKE_MODULES_INSTALL_DIR}
)
+
set(prefix "${CMAKE_INSTALL_PREFIX}")
set(exec_prefix "\${prefix}")
set(includedir "\${prefix}/include")
@@ -105,15 +114,5 @@ install(FILES
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)
-install(EXPORT Bcg729Targets
- FILE Bcg729Targets.cmake
- DESTINATION ${CONFIG_PACKAGE_LOCATION}
-)
-install(FILES
- "${PROJECT_BINARY_DIR}/Bcg729Config.cmake"
- "${PROJECT_BINARY_DIR}/Bcg729ConfigVersion.cmake"
- DESTINATION ${CONFIG_PACKAGE_LOCATION}
-)
add_subdirectory(build)
-
--- a/build/CMakeLists.txt
+++ b/build/CMakeLists.txt
@@ -1,6 +1,6 @@
############################################################################
# CMakeLists.txt
-# Copyright (C) 2017-2018 Belledonne Communications, Grenoble France
+# Copyright (C) 2017-2023 Belledonne Communications, Grenoble France
#
############################################################################
#
@@ -21,7 +21,8 @@
############################################################################
if(NOT CPACK_PACKAGE_NAME)
- set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
+ string(TOLOWER "${PROJECT_NAME}" LOWERCASE_PROJECT_NAME)
+ set(CPACK_PACKAGE_NAME "${LOWERCASE_PROJECT_NAME}")
ENDIF()
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/../LICENSE.txt")
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -49,11 +49,6 @@ set(BCG729_SOURCE_FILES
vad.c
)
-if(MSVC)
- set(MSVC_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include/MSVC")
- include_directories(${MSVC_INCLUDE_DIR})
-endif()
-
add_library(bcg729 ${BCG729_SOURCE_FILES})
target_compile_definitions(bcg729 PRIVATE "BCG729_EXPORTS")
set_target_properties(bcg729 PROPERTIES VERSION 0)
@@ -65,7 +60,6 @@ target_include_directories(bcg729
${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/src
${PROJECT_BINARY_DIR}
- ${MSVC_INCLUDE_DIR}
)
if(MSVC AND BUILD_SHARED_LIBS)
@@ -79,7 +73,7 @@ if(MSVC AND BUILD_SHARED_LIBS)
endif()
-install(TARGETS bcg729 EXPORT Bcg729Targets
+install(TARGETS bcg729 EXPORT ${PROJECT_NAME}Targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|