kopia lustrzana https://github.com/mobilinkd/m17-cxx-demod
cmake: Refactored code structure into library with examples
The project now supplies the m17cxx library in a form usable by third party applications. An example standalone CMake based app is included to as a reference or starting place. The modulation and demodulation utilities are included as apps.pull/9/head
rodzic
c1d954fd5e
commit
6622a947ae
|
@ -1,16 +1,26 @@
|
|||
cmake_minimum_required(VERSION 3.9)
|
||||
|
||||
project(m17-cxx-demod)
|
||||
enable_language(CXX)
|
||||
project(m17cxx
|
||||
VERSION 0.1
|
||||
DESCRIPTION "M17 Digital Voice modulation and demodulation"
|
||||
LANGUAGES CXX)
|
||||
|
||||
# C++17 is a required language feature for this project
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
# Require out-of-source builds
|
||||
file(TO_CMAKE_PATH "${PROJECT_BINARY_DIR}/CMakeLists.txt" LOC_PATH)
|
||||
if(EXISTS "${LOC_PATH}")
|
||||
message(FATAL_ERROR "You cannot build in a source directory (or any directory with a CMakeLists.txt file). Please make a build subdirectory. Feel free to remove CMakeCache.txt and CMakeFiles.")
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set (CMAKE_BUILD_TYPE Release)
|
||||
message(STATUS "Build type not specified: defaulting to release.")
|
||||
endif()
|
||||
|
||||
# Check for dependencies
|
||||
message(STATUS "# Checking dependencies")
|
||||
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
|
@ -18,20 +28,50 @@ include(FindPkgConfig)
|
|||
include(GNUInstallDirs)
|
||||
|
||||
pkg_check_modules(CODEC2 REQUIRED codec2)
|
||||
SET( Boost_USE_STATIC_LIBS FALSE )
|
||||
FIND_PACKAGE( Boost COMPONENTS program_options REQUIRED)
|
||||
set(Boost_USE_STATIC_LIBS FALSE)
|
||||
find_package(Boost COMPONENTS program_options REQUIRED)
|
||||
|
||||
add_executable(m17-demod m17-demod.cpp)
|
||||
target_link_libraries(m17-demod ${CODEC2_LIBRARIES})
|
||||
install(TARGETS m17-demod DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
add_executable(m17-mod m17-mod.cpp)
|
||||
target_link_libraries(m17-mod PRIVATE ${CODEC2_LIBRARIES} ${Boost_LIBRARIES})
|
||||
target_link_libraries(m17-mod PRIVATE Threads::Threads)
|
||||
install(TARGETS m17-mod DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
# Add subdirectories
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(apps)
|
||||
|
||||
find_package(GTest)
|
||||
if(GTEST_FOUND)
|
||||
enable_testing ()
|
||||
add_subdirectory (tests)
|
||||
endif()
|
||||
enable_testing()
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
||||
# Setup installation
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
write_basic_package_version_file(
|
||||
"${PROJECT_BINARY_DIR}/m17cxxConfigVersion.cmake"
|
||||
VERSION 0.1
|
||||
COMPATIBILITY AnyNewerVersion
|
||||
)
|
||||
|
||||
configure_package_config_file(
|
||||
"${PROJECT_SOURCE_DIR}/cmake/m17cxxConfig.cmake.in"
|
||||
"${PROJECT_BINARY_DIR}/m17cxxConfig.cmake"
|
||||
INSTALL_DESTINATION lib/cmake/m17cxx
|
||||
)
|
||||
|
||||
install(EXPORT m17cxxTargets DESTINATION lib/cmake/m17cxx)
|
||||
install(FILES "${PROJECT_BINARY_DIR}/m17cxxConfigVersion.cmake"
|
||||
"${PROJECT_BINARY_DIR}/m17cxxConfig.cmake"
|
||||
DESTINATION lib/cmake/m17cxx)
|
||||
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION include)
|
||||
|
||||
# Create uninstall target
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
|
||||
@ONLY)
|
||||
|
||||
add_custom_target(uninstall
|
||||
${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
|
||||
)
|
||||
|
||||
# Print summary
|
||||
message(STATUS "Using install prefix: ${CMAKE_INSTALL_PREFIX}")
|
||||
message(STATUS "Building version: ${PROJECT_VERSION}")
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
add_executable(m17-demod m17-demod.cpp)
|
||||
target_link_libraries(m17-demod PRIVATE m17cxx ${CODEC2_LIBRARIES})
|
||||
|
||||
add_executable(m17-mod m17-mod.cpp)
|
||||
target_link_libraries(m17-mod PRIVATE m17cxx ${CODEC2_LIBRARIES} ${Boost_LIBRARIES} Threads::Threads)
|
||||
|
||||
install(TARGETS m17-demod m17-mod RUNTIME DESTINATION bin)
|
|
@ -0,0 +1,32 @@
|
|||
# http://www.vtk.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F
|
||||
|
||||
IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||
MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
|
||||
ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||
|
||||
FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
|
||||
STRING(REGEX REPLACE "\n" ";" files "${files}")
|
||||
FOREACH(file ${files})
|
||||
MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
|
||||
IF(EXISTS "$ENV{DESTDIR}${file}")
|
||||
EXEC_PROGRAM(
|
||||
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
|
||||
OUTPUT_VARIABLE rm_out
|
||||
RETURN_VALUE rm_retval
|
||||
)
|
||||
IF(NOT "${rm_retval}" STREQUAL 0)
|
||||
MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
|
||||
ENDIF(NOT "${rm_retval}" STREQUAL 0)
|
||||
ELSEIF(IS_SYMLINK "$ENV{DESTDIR}${file}")
|
||||
EXEC_PROGRAM(
|
||||
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
|
||||
OUTPUT_VARIABLE rm_out
|
||||
RETURN_VALUE rm_retval
|
||||
)
|
||||
IF(NOT "${rm_retval}" STREQUAL 0)
|
||||
MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
|
||||
ENDIF(NOT "${rm_retval}" STREQUAL 0)
|
||||
ELSE(EXISTS "$ENV{DESTDIR}${file}")
|
||||
MESSAGE(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
|
||||
ENDIF(EXISTS "$ENV{DESTDIR}${file}")
|
||||
ENDFOREACH(file)
|
|
@ -0,0 +1,4 @@
|
|||
@PACKAGE_INIT@
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/m17cxxTargets.cmake")
|
||||
check_required_components("@PROJECT_NAME@")
|
|
@ -0,0 +1,18 @@
|
|||
cmake_minimum_required(VERSION 3.9)
|
||||
|
||||
project(m17-example
|
||||
VERSION 0.1
|
||||
DESCRIPTION "Standalone example M17 project"
|
||||
LANGUAGES CXX)
|
||||
|
||||
find_package(m17cxx CONFIG REQUIRED)
|
||||
if(${m17cxx_FOUND})
|
||||
message(STATUS "Found m17cxx")
|
||||
message(STATUS " M17 Library version: " ${m17cxx_VERSION})
|
||||
message(STATUS " M17 Library location: " ${m17cxx_DIR})
|
||||
else(${m17cxx_FOUND})
|
||||
message(FATAL_ERROR "Could not locate m17cxx")
|
||||
endif()
|
||||
|
||||
add_executable(example example.cpp)
|
||||
target_link_libraries(example m17cxx)
|
|
@ -0,0 +1,5 @@
|
|||
#include <m17cxx/M17Modulator.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
add_library(m17cxx INTERFACE)
|
||||
|
||||
target_include_directories(m17cxx INTERFACE
|
||||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/m17cxx>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
)
|
||||
|
||||
target_compile_features(m17cxx INTERFACE cxx_std_17)
|
||||
|
||||
source_group(
|
||||
TREE "${PROJECT_SOURCE_DIR}/include"
|
||||
PREFIX "Header Files"
|
||||
FILES ${HEADER_LIST})
|
||||
|
||||
install(TARGETS m17cxx
|
||||
EXPORT m17cxxTargets
|
||||
LIBRARY DESTINATION lib COMPONENT Runtime
|
||||
ARCHIVE DESTINATION lib COMPONENT Development
|
||||
RUNTIME DESTINATION bin COMPONENT Runtime
|
||||
PUBLIC_HEADER DESTINATION include COMPONENT Development
|
||||
BUNDLE DESTINATION bin COMPONENT Runtime
|
||||
INCLUDES DESTINATION include
|
||||
)
|
||||
|
|
@ -7,45 +7,45 @@ include_directories (
|
|||
)
|
||||
|
||||
add_executable (ConvolutionTest ConvolutionTest.cpp)
|
||||
target_link_libraries(ConvolutionTest gtest pthread)
|
||||
target_link_libraries(ConvolutionTest m17cxx gtest pthread)
|
||||
gtest_add_tests(ConvolutionTest "" AUTO)
|
||||
|
||||
add_executable (M17FramerTest M17FramerTest.cpp)
|
||||
target_link_libraries(M17FramerTest gtest pthread)
|
||||
target_link_libraries(M17FramerTest m17cxx gtest pthread)
|
||||
gtest_add_tests(M17FramerTest "" AUTO)
|
||||
|
||||
add_executable (TrellisTest TrellisTest.cpp)
|
||||
target_link_libraries(TrellisTest gtest pthread)
|
||||
target_link_libraries(TrellisTest m17cxx gtest pthread)
|
||||
gtest_add_tests(TrellisTest "" AUTO)
|
||||
|
||||
add_executable (ViterbiTest ViterbiTest.cpp)
|
||||
target_link_libraries(ViterbiTest gtest pthread)
|
||||
target_link_libraries(ViterbiTest m17cxx gtest pthread)
|
||||
gtest_add_tests(ViterbiTest "" AUTO)
|
||||
|
||||
add_executable (Golay24Test Golay24Test.cpp)
|
||||
target_link_libraries(Golay24Test gtest pthread)
|
||||
target_link_libraries(Golay24Test m17cxx gtest pthread)
|
||||
gtest_add_tests(Golay24Test "" AUTO)
|
||||
|
||||
add_executable (CRC16Test CRC16Test.cpp)
|
||||
target_link_libraries(CRC16Test gtest pthread)
|
||||
target_link_libraries(CRC16Test m17cxx gtest pthread)
|
||||
gtest_add_tests(CRC16Test "" AUTO)
|
||||
|
||||
add_executable (M17RandomizerTest M17RandomizerTest.cpp)
|
||||
target_link_libraries(M17RandomizerTest gtest pthread)
|
||||
target_link_libraries(M17RandomizerTest m17cxx gtest pthread)
|
||||
gtest_add_tests(M17RandomizerTest "" AUTO)
|
||||
|
||||
add_executable (PolynomialInterleaverTest PolynomialInterleaverTest.cpp)
|
||||
target_link_libraries(PolynomialInterleaverTest gtest pthread)
|
||||
target_link_libraries(PolynomialInterleaverTest m17cxx gtest pthread)
|
||||
gtest_add_tests(PolynomialInterleaverTest "" AUTO)
|
||||
|
||||
add_executable (M17ModulatorTest M17ModulatorTest.cpp)
|
||||
target_link_libraries(M17ModulatorTest gtest pthread codec2)
|
||||
target_link_libraries(M17ModulatorTest m17cxx gtest pthread codec2)
|
||||
gtest_add_tests(M17ModulatorTest "" AUTO)
|
||||
|
||||
add_executable (UtilTest UtilTest.cpp)
|
||||
target_link_libraries(UtilTest gtest pthread)
|
||||
target_link_libraries(UtilTest m17cxx gtest pthread)
|
||||
gtest_add_tests(UtilTest "" AUTO)
|
||||
|
||||
add_executable (LinkSetupFrameTest LinkSetupFrameTest.cpp)
|
||||
target_link_libraries(LinkSetupFrameTest gtest pthread)
|
||||
target_link_libraries(LinkSetupFrameTest m17cxx gtest pthread)
|
||||
gtest_add_tests(LinkSetupFrameTest "" AUTO)
|
||||
|
|
Ładowanie…
Reference in New Issue