0001-update-cmake.patch 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. From 812d69af486e608a10380ed5817b03d08c6e786a Mon Sep 17 00:00:00 2001
  2. From: "A. Maitland Bottoms" <bottoms@debian.org>
  3. Date: Sun, 17 Jul 2022 17:04:44 -0400
  4. Subject: [PATCH] update cmake
  5. Some minor refactoring of Codec2 build to better use CMake
  6. features to improve readability ans maintainability.
  7. [Retrieved from:
  8. https://github.com/drowe67/codec2/commit/812d69af486e608a10380ed5817b03d08c6e786a]
  9. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  10. ---
  11. CMakeLists.txt | 48 +++++---------------------
  12. src/CMakeLists.txt | 84 ++++++++++++++++++++++++----------------------
  13. 2 files changed, 53 insertions(+), 79 deletions(-)
  14. diff --git a/CMakeLists.txt b/CMakeLists.txt
  15. index 54ac1f4f4..998af5ddf 100644
  16. --- a/CMakeLists.txt
  17. +++ b/CMakeLists.txt
  18. @@ -5,19 +5,13 @@
  19. # Please report questions, comments, problems, or patches to the freetel
  20. # mailing list: https://lists.sourceforge.net/lists/listinfo/freetel-codec2
  21. #
  22. -set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "Minimum OS X deployment version")
  23. -
  24. -project(codec2)
  25. -
  26. -cmake_minimum_required(VERSION 3.0)
  27. -
  28. -# Set policies here, probably should move to cmake dir.
  29. -if(POLICY CMP0075)
  30. - cmake_policy(SET CMP0075 NEW)
  31. -endif()
  32. -if(POLICY CMP0079)
  33. - cmake_policy(SET CMP0079 NEW)
  34. -endif()
  35. +cmake_minimum_required(VERSION 3.13)
  36. +project(CODEC2
  37. + VERSION 1.0.5
  38. + DESCRIPTION "Next-Generation Digital Voice for Two-Way Radio"
  39. + HOMEPAGE_URL "https://www.rowetel.com/codec2.html"
  40. + LANGUAGES C
  41. + )
  42. include(GNUInstallDirs)
  43. mark_as_advanced(CLEAR
  44. @@ -39,23 +33,6 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
  45. "separate build directory and run cmake from there.")
  46. endif("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
  47. -#
  48. -# Set project version information. This should probably be done via external
  49. -# file at some point.
  50. -#
  51. -set(CODEC2_VERSION_MAJOR 1)
  52. -set(CODEC2_VERSION_MINOR 0)
  53. -# Set to patch level if needed, otherwise leave FALSE.
  54. -# Must be positive (non-zero) if set, since 0 == FALSE in CMake.
  55. -set(CODEC2_VERSION_PATCH 5)
  56. -set(CODEC2_VERSION "${CODEC2_VERSION_MAJOR}.${CODEC2_VERSION_MINOR}")
  57. -# Patch level version bumps should not change API/ABI.
  58. -set(SOVERSION "${CODEC2_VERSION_MAJOR}.${CODEC2_VERSION_MINOR}")
  59. -if(CODEC2_VERSION_PATCH)
  60. - set(CODEC2_VERSION "${CODEC2_VERSION}.${CODEC2_VERSION_PATCH}")
  61. -endif()
  62. -message(STATUS "codec2 version: ${CODEC2_VERSION}")
  63. -
  64. # Set default build type
  65. if(NOT CMAKE_BUILD_TYPE)
  66. set(CMAKE_BUILD_TYPE "Debug")
  67. @@ -65,6 +42,7 @@ endif()
  68. if(BUILD_OSX_UNIVERSAL)
  69. set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64")
  70. endif(BUILD_OSX_UNIVERSAL)
  71. +set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "Minimum OS X deployment version")
  72. #
  73. # Find the git hash if this is a working copy.
  74. @@ -190,10 +168,6 @@ if (_GNU_SOURCE)
  75. add_definitions(-D_GNU_SOURCE=1)
  76. endif()
  77. -if(UNIX)
  78. - set(CMAKE_REQUIRED_LIBRARIES m)
  79. -endif()
  80. -
  81. check_symbol_exists(floor math.h HAVE_FLOOR)
  82. check_symbol_exists(ceil math.h HAVE_CEIL)
  83. check_symbol_exists(pow math.h HAVE_POW)
  84. @@ -288,11 +262,7 @@ else()
  85. endif()
  86. # Return the date (yyyy-mm-dd)
  87. -macro(DATE RESULT)
  88. - execute_process(COMMAND "date" "+%Y%m%d" OUTPUT_VARIABLE ${RESULT})
  89. -endmacro()
  90. -DATE(DATE_RESULT)
  91. -string(REGEX REPLACE "\n$" "" DATE_RESULT "${DATE_RESULT}")
  92. +string(TIMESTAMP DATE_RESULT "%Y-%m-%d" UTC)
  93. message(STATUS "Compilation date = XX${DATE_RESULT}XX")
  94. set(CPACK_PACKAGE_VERSION_PATCH "${CPACK_PACKAGE_VERSION_PATCH}-${DATE_RESULT}-${FREEDV_HASH}")
  95. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
  96. index 642404962..cb0990bc2 100644
  97. --- a/src/CMakeLists.txt
  98. +++ b/src/CMakeLists.txt
  99. @@ -81,7 +81,7 @@ else(CMAKE_CROSSCOMPILING)
  100. # Build code generator binaries. These do not get installed.
  101. # generate_codebook
  102. add_executable(generate_codebook generate_codebook.c)
  103. - target_link_libraries(generate_codebook m ${CMAKE_REQUIRED_LIBRARIES})
  104. + target_link_libraries(generate_codebook m)
  105. # Make native builds available for cross-compiling.
  106. export(TARGETS generate_codebook
  107. FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake)
  108. @@ -238,12 +238,16 @@ set(CODEC2_PUBLIC_HEADERS
  109. #
  110. # Setup the codec2 library
  111. #
  112. +# Patch level version bumps should not change API/ABI.
  113. +set(SOVERSION "${CODEC2_VERSION_MAJOR}.${CODEC2_VERSION_MINOR}")
  114. +message(STATUS "codec2 version: ${CODEC2_VERSION}")
  115. add_library(codec2 ${CODEC2_SRCS})
  116. if(UNIX)
  117. - target_link_libraries(codec2 m)
  118. + target_link_libraries(codec2 PUBLIC m)
  119. endif(UNIX)
  120. if(LPCNET AND lpcnetfreedv_FOUND)
  121. - target_link_libraries(codec2 lpcnetfreedv)
  122. + target_link_libraries(codec2 PRIVATE lpcnetfreedv)
  123. + list(APPEND CODEC2_PUBLIC_HEADERS ${CMAKE_SOURCE_DIR}/lpcnet/src/lpcnet_freedv.h)
  124. endif()
  125. include_directories(${CMAKE_CURRENT_SOURCE_DIR})
  126. set_target_properties(codec2 PROPERTIES
  127. @@ -269,70 +273,70 @@ export(TARGETS codec2
  128. )
  129. add_executable(c2enc c2enc.c)
  130. -target_link_libraries(c2enc ${CMAKE_REQUIRED_LIBRARIES} codec2)
  131. +target_link_libraries(c2enc codec2)
  132. add_executable(c2dec c2dec.c)
  133. -target_link_libraries(c2dec ${CMAKE_REQUIRED_LIBRARIES} codec2)
  134. +target_link_libraries(c2dec codec2)
  135. add_executable(c2sim c2sim.c sd.c)
  136. -target_link_libraries(c2sim ${CMAKE_REQUIRED_LIBRARIES} codec2)
  137. +target_link_libraries(c2sim codec2)
  138. add_executable(fdmdv_get_test_bits fdmdv_get_test_bits.c fdmdv.c kiss_fft.c codec2_fft.c kiss_fftr.c)
  139. -target_link_libraries(fdmdv_get_test_bits m ${CMAKE_REQUIRED_LIBRARIES})
  140. +target_link_libraries(fdmdv_get_test_bits m)
  141. add_executable(fdmdv_mod fdmdv_mod.c fdmdv.c kiss_fft.c codec2_fft.c kiss_fftr.c)
  142. -target_link_libraries(fdmdv_mod m ${CMAKE_REQUIRED_LIBRARIES})
  143. +target_link_libraries(fdmdv_mod m)
  144. add_executable(fdmdv_demod fdmdv_demod.c fdmdv.c kiss_fft.c octave.c modem_stats.c codec2_fft.c kiss_fftr.c)
  145. -target_link_libraries(fdmdv_demod m ${CMAKE_REQUIRED_LIBRARIES})
  146. +target_link_libraries(fdmdv_demod m)
  147. add_executable(fdmdv_put_test_bits fdmdv_put_test_bits.c fdmdv.c kiss_fft.c codec2_fft.c kiss_fftr.c)
  148. -target_link_libraries(fdmdv_put_test_bits m ${CMAKE_REQUIRED_LIBRARIES})
  149. +target_link_libraries(fdmdv_put_test_bits m)
  150. add_executable(fdmdv_channel fdmdv_channel.c)
  151. -target_link_libraries(fdmdv_channel ${CMAKE_REQUIRED_LIBRARIES} codec2)
  152. +target_link_libraries(fdmdv_channel codec2)
  153. add_executable(insert_errors insert_errors.c)
  154. -target_link_libraries(insert_errors ${CMAKE_REQUIRED_LIBRARIES})
  155. +target_link_libraries(insert_errors)
  156. add_executable(freedv_tx freedv_tx.c)
  157. -target_link_libraries(freedv_tx ${CMAKE_REQUIRED_LIBRARIES} codec2)
  158. +target_link_libraries(freedv_tx codec2)
  159. add_executable(freedv_rx freedv_rx.c)
  160. -target_link_libraries(freedv_rx ${CMAKE_REQUIRED_LIBRARIES} codec2)
  161. +target_link_libraries(freedv_rx codec2)
  162. add_executable(freedv_data_raw_tx freedv_data_raw_tx.c)
  163. -target_link_libraries(freedv_data_raw_tx ${CMAKE_REQUIRED_LIBRARIES} codec2)
  164. +target_link_libraries(freedv_data_raw_tx codec2)
  165. add_executable(freedv_data_raw_rx freedv_data_raw_rx.c octave.c)
  166. -target_link_libraries(freedv_data_raw_rx ${CMAKE_REQUIRED_LIBRARIES} codec2)
  167. +target_link_libraries(freedv_data_raw_rx codec2)
  168. add_executable(freedv_data_tx freedv_data_tx.c)
  169. -target_link_libraries(freedv_data_tx ${CMAKE_REQUIRED_LIBRARIES} codec2)
  170. +target_link_libraries(freedv_data_tx codec2)
  171. add_executable(freedv_data_rx freedv_data_rx.c)
  172. -target_link_libraries(freedv_data_rx ${CMAKE_REQUIRED_LIBRARIES} codec2)
  173. +target_link_libraries(freedv_data_rx codec2)
  174. add_executable(freedv_mixed_tx freedv_mixed_tx.c)
  175. -target_link_libraries(freedv_mixed_tx ${CMAKE_REQUIRED_LIBRARIES} codec2)
  176. +target_link_libraries(freedv_mixed_tx codec2)
  177. add_executable(freedv_mixed_rx freedv_mixed_rx.c)
  178. -target_link_libraries(freedv_mixed_rx ${CMAKE_REQUIRED_LIBRARIES} codec2)
  179. +target_link_libraries(freedv_mixed_rx codec2)
  180. add_executable(fsk_mod fsk_mod.c)
  181. -target_link_libraries(fsk_mod ${CMAKE_REQUIRED_LIBRARIES} codec2)
  182. +target_link_libraries(fsk_mod codec2)
  183. add_executable(fsk_mod_ext_vco fsk_mod_ext_vco.c)
  184. -target_link_libraries(fsk_mod_ext_vco m ${CMAKE_REQUIRED_LIBRARIES})
  185. +target_link_libraries(fsk_mod_ext_vco m)
  186. add_executable(fsk_demod fsk_demod.c modem_probe.c octave.c)
  187. -target_link_libraries(fsk_demod ${CMAKE_REQUIRED_LIBRARIES} codec2)
  188. +target_link_libraries(fsk_demod codec2)
  189. add_executable(fsk_get_test_bits fsk_get_test_bits.c)
  190. target_link_libraries(fsk_get_test_bits)
  191. add_executable(fsk_put_test_bits fsk_put_test_bits.c)
  192. -target_link_libraries(fsk_put_test_bits ${CMAKE_REQUIRED_LIBRARIES} codec2)
  193. +target_link_libraries(fsk_put_test_bits codec2)
  194. add_executable(framer framer.c)
  195. target_link_libraries(framer)
  196. @@ -341,46 +345,46 @@ add_executable(deframer deframer.c)
  197. target_link_libraries(deframer)
  198. add_executable(fm_demod fm_demod.c fm.c)
  199. -target_link_libraries(fm_demod m ${CMAKE_REQUIRED_LIBRARIES})
  200. +target_link_libraries(fm_demod m)
  201. add_executable(cohpsk_mod cohpsk_mod.c)
  202. -target_link_libraries(cohpsk_mod ${CMAKE_REQUIRED_LIBRARIES} codec2)
  203. +target_link_libraries(cohpsk_mod codec2)
  204. add_executable(ofdm_get_test_bits ofdm_get_test_bits.c)
  205. -target_link_libraries(ofdm_get_test_bits ${CMAKE_REQUIRED_LIBRARIES} codec2)
  206. +target_link_libraries(ofdm_get_test_bits codec2)
  207. add_executable(ofdm_put_test_bits ofdm_put_test_bits.c)
  208. -target_link_libraries(ofdm_put_test_bits ${CMAKE_REQUIRED_LIBRARIES} codec2)
  209. +target_link_libraries(ofdm_put_test_bits codec2)
  210. add_executable(ofdm_mod ofdm_mod.c)
  211. -target_link_libraries(ofdm_mod ${CMAKE_REQUIRED_LIBRARIES} codec2)
  212. +target_link_libraries(ofdm_mod codec2)
  213. add_executable(ofdm_demod ofdm_demod.c octave.c)
  214. -target_link_libraries(ofdm_demod ${CMAKE_REQUIRED_LIBRARIES} codec2)
  215. +target_link_libraries(ofdm_demod codec2)
  216. add_executable(fmfsk_mod fmfsk_mod.c)
  217. -target_link_libraries(fmfsk_mod ${CMAKE_REQUIRED_LIBRARIES} codec2)
  218. +target_link_libraries(fmfsk_mod codec2)
  219. add_executable(fmfsk_demod fmfsk_demod.c modem_probe.c octave.c)
  220. -target_link_libraries(fmfsk_demod ${CMAKE_REQUIRED_LIBRARIES} codec2)
  221. +target_link_libraries(fmfsk_demod codec2)
  222. add_executable(vhf_deframe_c2 vhf_deframe_c2.c)
  223. -target_link_libraries(vhf_deframe_c2 ${CMAKE_REQUIRED_LIBRARIES} codec2)
  224. +target_link_libraries(vhf_deframe_c2 codec2)
  225. add_executable(vhf_frame_c2 vhf_frame_c2.c)
  226. -target_link_libraries(vhf_frame_c2 ${CMAKE_REQUIRED_LIBRARIES} codec2)
  227. +target_link_libraries(vhf_frame_c2 codec2)
  228. add_executable(cohpsk_demod cohpsk_demod.c octave.c)
  229. -target_link_libraries(cohpsk_demod ${CMAKE_REQUIRED_LIBRARIES} codec2)
  230. +target_link_libraries(cohpsk_demod codec2)
  231. add_executable(cohpsk_get_test_bits cohpsk_get_test_bits.c)
  232. -target_link_libraries(cohpsk_get_test_bits ${CMAKE_REQUIRED_LIBRARIES} codec2)
  233. +target_link_libraries(cohpsk_get_test_bits codec2)
  234. add_executable(cohpsk_put_test_bits cohpsk_put_test_bits.c octave.c)
  235. -target_link_libraries(cohpsk_put_test_bits ${CMAKE_REQUIRED_LIBRARIES} codec2)
  236. +target_link_libraries(cohpsk_put_test_bits codec2)
  237. add_executable(ch ch.c)
  238. -target_link_libraries(ch ${CMAKE_REQUIRED_LIBRARIES} codec2)
  239. +target_link_libraries(ch codec2)
  240. add_executable(tollr tollr.c)
  241. @@ -388,10 +392,10 @@ add_executable(ldpc_noise ldpc_noise.c)
  242. target_link_libraries(ldpc_noise m)
  243. add_executable(ldpc_enc ldpc_enc.c)
  244. -target_link_libraries(ldpc_enc ${CMAKE_REQUIRED_LIBRARIES} codec2)
  245. +target_link_libraries(ldpc_enc codec2)
  246. add_executable(ldpc_dec ldpc_dec.c)
  247. -target_link_libraries(ldpc_dec ${CMAKE_REQUIRED_LIBRARIES} codec2)
  248. +target_link_libraries(ldpc_dec codec2)
  249. install(TARGETS codec2 EXPORT codec2-config
  250. LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib