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
|
Author: A. Maitland Bottoms <bottoms@debian.org>
Subject: modern cmake targets
Updating cmake_minimum_required to 2.8.12 allows exporting
targets. Also, target dependencies are transitive, so this patch
also simplifies the target_link_libraries for many executables.
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,10 +5,8 @@
# Please report questions, comments, problems, or patches to the freetel
# mailing list: https://lists.sourceforge.net/lists/listinfo/freetel-codec2
#
+cmake_minimum_required(VERSION 2.8.12)
project(codec2 C)
-
-cmake_minimum_required(VERSION 2.8)
-
include(GNUInstallDirs)
mark_as_advanced(CLEAR
CMAKE_INSTALL_BINDIR
@@ -248,3 +246,11 @@
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
COMPONENT "codec2_devel"
)
+# ... and export CMake targets
+install(FILES
+ ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Codec2Config.cmake
+ #${CMAKE_CURRENT_BINARY_DIR}/cmake/Codec2ConfigVersion.cmake
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/codec2
+ )
+install(EXPORT codec2-config FILE Codec2Targets.cmake
+ NAMESPACE Codec2:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/codec2 )
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -266,16 +266,16 @@
)
add_executable(c2demo c2demo.c)
-target_link_libraries(c2demo ${CMAKE_REQUIRED_LIBRARIES} codec2)
+target_link_libraries(c2demo codec2)
add_executable(c2enc c2enc.c)
-target_link_libraries(c2enc ${CMAKE_REQUIRED_LIBRARIES} codec2)
+target_link_libraries(c2enc codec2)
add_executable(c2dec c2dec.c)
-target_link_libraries(c2dec ${CMAKE_REQUIRED_LIBRARIES} codec2)
+target_link_libraries(c2dec codec2)
add_executable(c2sim c2sim.c)
-target_link_libraries(c2sim ${CMAKE_REQUIRED_LIBRARIES} codec2)
+target_link_libraries(c2sim codec2)
add_executable(fdmdv_get_test_bits fdmdv_get_test_bits.c fdmdv.c kiss_fft.c codec2_fft.c kiss_fftr.c)
target_link_libraries(fdmdv_get_test_bits ${CMAKE_REQUIRED_LIBRARIES})
@@ -290,7 +290,7 @@
target_link_libraries(fdmdv_put_test_bits ${CMAKE_REQUIRED_LIBRARIES})
add_executable(fdmdv_channel fdmdv_channel.c)
-target_link_libraries(fdmdv_channel ${CMAKE_REQUIRED_LIBRARIES} codec2)
+target_link_libraries(fdmdv_channel codec2)
add_executable(fdmdv_interleave fdmdv_interleave.c)
target_link_libraries(fdmdv_interleave ${CMAKE_REQUIRED_LIBRARIES})
@@ -299,85 +299,85 @@
target_link_libraries(insert_errors ${CMAKE_REQUIRED_LIBRARIES})
add_executable(fec_enc fec_enc.c golay23.c)
-target_link_libraries(fec_enc ${CMAKE_REQUIRED_LIBRARIES} codec2)
+target_link_libraries(fec_enc codec2)
add_executable(fec_dec fec_dec.c golay23.c)
-target_link_libraries(fec_dec ${CMAKE_REQUIRED_LIBRARIES} codec2)
+target_link_libraries(fec_dec codec2)
add_executable(freedv_tx freedv_tx.c)
-target_link_libraries(freedv_tx ${CMAKE_REQUIRED_LIBRARIES} codec2)
+target_link_libraries(freedv_tx codec2)
add_executable(freedv_rx freedv_rx.c)
-target_link_libraries(freedv_rx ${CMAKE_REQUIRED_LIBRARIES} codec2)
+target_link_libraries(freedv_rx codec2)
add_executable(fsk_mod fsk_mod.c)
-target_link_libraries(fsk_mod ${CMAKE_REQUIRED_LIBRARIES} codec2)
+target_link_libraries(fsk_mod codec2)
add_executable(fsk_mod_ext_vco fsk_mod_ext_vco.c)
target_link_libraries(fsk_mod_ext_vco ${CMAKE_REQUIRED_LIBRARIES})
add_executable(fsk_demod fsk_demod.c modem_probe.c octave.c)
-target_link_libraries(fsk_demod ${CMAKE_REQUIRED_LIBRARIES} codec2)
+target_link_libraries(fsk_demod codec2)
add_executable(fsk_get_test_bits fsk_get_test_bits.c)
target_link_libraries(fsk_get_test_bits)
add_executable(fsk_put_test_bits fsk_put_test_bits.c)
-target_link_libraries(fsk_put_test_bits ${CMAKE_REQUIRED_LIBRARIES} codec2)
+target_link_libraries(fsk_put_test_bits codec2)
add_executable(fm_demod fm_demod.c fm.c)
target_link_libraries(fm_demod ${CMAKE_REQUIRED_LIBRARIES})
add_executable(cohpsk_mod cohpsk_mod.c)
-target_link_libraries(cohpsk_mod ${CMAKE_REQUIRED_LIBRARIES} codec2)
+target_link_libraries(cohpsk_mod codec2)
add_executable(ofdm_get_test_bits ofdm_get_test_bits.c)
-target_link_libraries(ofdm_get_test_bits ${CMAKE_REQUIRED_LIBRARIES} codec2)
+target_link_libraries(ofdm_get_test_bits codec2)
add_executable(ofdm_put_test_bits ofdm_put_test_bits.c)
-target_link_libraries(ofdm_put_test_bits ${CMAKE_REQUIRED_LIBRARIES} codec2)
+target_link_libraries(ofdm_put_test_bits codec2)
add_executable(ofdm_mod ofdm_mod.c)
-target_link_libraries(ofdm_mod ${CMAKE_REQUIRED_LIBRARIES} codec2)
+target_link_libraries(ofdm_mod codec2)
add_executable(ofdm_demod ofdm_demod.c octave.c)
-target_link_libraries(ofdm_demod ${CMAKE_REQUIRED_LIBRARIES} codec2)
+target_link_libraries(ofdm_demod codec2)
add_executable(fmfsk_mod fmfsk_mod.c)
-target_link_libraries(fmfsk_mod ${CMAKE_REQUIRED_LIBRARIES} codec2)
+target_link_libraries(fmfsk_mod codec2)
add_executable(fmfsk_demod fmfsk_demod.c modem_probe.c octave.c)
-target_link_libraries(fmfsk_demod ${CMAKE_REQUIRED_LIBRARIES} codec2)
+target_link_libraries(fmfsk_demod codec2)
add_executable(vhf_deframe_c2 vhf_deframe_c2.c)
-target_link_libraries(vhf_deframe_c2 ${CMAKE_REQUIRED_LIBRARIES} codec2)
+target_link_libraries(vhf_deframe_c2 codec2)
add_executable(vhf_frame_c2 vhf_frame_c2.c)
-target_link_libraries(vhf_frame_c2 ${CMAKE_REQUIRED_LIBRARIES} codec2)
+target_link_libraries(vhf_frame_c2 codec2)
add_executable(cohpsk_demod cohpsk_demod.c octave.c)
-target_link_libraries(cohpsk_demod ${CMAKE_REQUIRED_LIBRARIES} codec2)
+target_link_libraries(cohpsk_demod codec2)
add_executable(cohpsk_get_test_bits cohpsk_get_test_bits.c)
-target_link_libraries(cohpsk_get_test_bits ${CMAKE_REQUIRED_LIBRARIES} codec2)
+target_link_libraries(cohpsk_get_test_bits codec2)
add_executable(cohpsk_put_test_bits cohpsk_put_test_bits.c octave.c)
-target_link_libraries(cohpsk_put_test_bits ${CMAKE_REQUIRED_LIBRARIES} codec2)
+target_link_libraries(cohpsk_put_test_bits codec2)
add_executable(cohpsk_ch cohpsk_ch.c)
-target_link_libraries(cohpsk_ch ${CMAKE_REQUIRED_LIBRARIES} codec2)
+target_link_libraries(cohpsk_ch codec2)
add_executable(ldpc_enc ldpc_enc.c)
-target_link_libraries(ldpc_enc ${CMAKE_REQUIRED_LIBRARIES} codec2)
+target_link_libraries(ldpc_enc codec2)
add_executable(ldpc_dec ldpc_dec.c)
-target_link_libraries(ldpc_dec ${CMAKE_REQUIRED_LIBRARIES} codec2)
+target_link_libraries(ldpc_dec codec2)
add_executable(drs232 drs232.c)
target_link_libraries(drs232 ${CMAKE_REQUIRED_LIBRARIES})
add_executable(drs232_ldpc drs232_ldpc.c)
-target_link_libraries(drs232_ldpc ${CMAKE_REQUIRED_LIBRARIES} codec2)
+target_link_libraries(drs232_ldpc codec2)
add_definitions(-DHORUS_L2_RX -DINTERLEAVER -DSCRAMBLER)
add_executable(horus_demod horus_demod.c horus_api.c horus_l2.c fsk.c kiss_fft.c)
@@ -390,10 +390,6 @@
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/codec2
)
-#install(EXPORT codec2-config
-# DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/codec2
-#)
-
install(TARGETS
c2demo
c2demo
--- /dev/null
+++ b/cmake/Codec2Config.cmake
@@ -0,0 +1,8 @@
+get_filename_component(CODEC2_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
+
+if(NOT TARGET Codec2::codec2)
+ include("${CODEC2_CMAKE_DIR}/Codec2Targets.cmake")
+endif()
+
+# Backwards compatability
+set(Codec2_LIBRARIES Codec2::codec2)
|