From e4d3dca5b0318c1776d1447016172a35ad3fd1d8 Mon Sep 17 00:00:00 2001 From: Martin Hauke Date: Sun, 30 Aug 2015 00:03:46 +0200 Subject: [PATCH 1/2] Add CMake support --- CMakeLists.txt | 25 +++++++++ cmake/cmake_uninstall.cmake.in | 21 ++++++++ src/CMakeLists.txt | 94 ++++++++++++++++++++++++++++++++++ 3 files changed, 140 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 cmake/cmake_uninstall.cmake.in create mode 100644 src/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..e1673bb --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,25 @@ +######################################################################## +# Project setup +######################################################################## + +cmake_minimum_required(VERSION 2.8) + +# dabtools +add_subdirectory(src) + +# wavefinder-driver +# add_subdirectory(wavefinder-driver) + + +######################################################################## +# Create uninstall target +######################################################################## + +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" + IMMEDIATE @ONLY) + +add_custom_target(uninstall + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) + diff --git a/cmake/cmake_uninstall.cmake.in b/cmake/cmake_uninstall.cmake.in new file mode 100644 index 0000000..2037e36 --- /dev/null +++ b/cmake/cmake_uninstall.cmake.in @@ -0,0 +1,21 @@ +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(IS_SYMLINK "$ENV{DESTDIR}${file}" OR 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) + else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") + message(STATUS "File $ENV{DESTDIR}${file} does not exist.") + endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") +endforeach(file) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..508d33f --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,94 @@ +######################################################################## +# Project setup +######################################################################## + +cmake_minimum_required(VERSION 2.8) +project(dabtools C) + +# Select the release build type by default to get optimization flags +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release") + message(STATUS "Build type not specified: defaulting to release.") +endif(NOT CMAKE_BUILD_TYPE) +set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "") + +list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules) + +# Set the version information here +set(VERSION_INFO_MAJOR_VERSION 0) +set(VERSION_INFO_API_COMPAT 0) +set(VERSION_INFO_MINOR_VERSION 0) +set(VERSION_INFO_MAINT_VERSION git) + + +######################################################################## +# Compiler specific setup +######################################################################## + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -W -Wall") + + +######################################################################## +# Find build dependencies +######################################################################## + +find_package(PkgConfig) +# pthreads +find_package(Threads REQUIRED) +# rtlsdr +pkg_check_modules(RTLSDR librtlsdr REQUIRED) +include_directories(${RTLSDR_INCLUDE_DIRS}) +# fftw3 +pkg_check_modules(FFTW3 fftw3 REQUIRED ) +include_directories(${FFTW3_INCLUDE_DIRS}) + + +######################################################################## +# Setup apps +######################################################################## + +list(APPEND dabtools_sources + dab.c + dab_tables.c + depuncture.c + fic.c + input_sdr.c + input_wf.c + misc.c + sdr_fifo.c +# sdr_prstab.c + sdr_sync.c + wf_maths.c + wf_prstables.c + wf_sync.c + dab2eti.c + ) + +if(ENABLE_SPIRAL_VITERBI) + list(APPEND dabtools_sources + ${dabtools_sources} + viterbi_spiral.c + viterbi_spiral_sse16.c + ) + add_definitions( + -DENABLE_SPIRAL_VITERBI + -msse2 + -msse3 + -std=gnu99 + ) +else() + list(APPEND dabtools_sources + ${dabtools_sources} + viterbi.c) +endif() + +add_executable(dab2eti ${dabtools_sources}) +add_executable(eti2mpa eti2mpa.c) +target_link_libraries(dab2eti m ${CMAKE_THREAD_LIBS_INIT} ${FFTW3_LIBRARIES} ${RTLSDR_LIBRARIES}) + +install(TARGETS + dab2eti + eti2mpa + DESTINATION bin +) + From 1268833571e0bfef9d22e08113c45b2785d7c807 Mon Sep 17 00:00:00 2001 From: Martin Hauke Date: Fri, 4 Sep 2015 23:42:44 +0200 Subject: [PATCH 2/2] adjust CFLAGS --- src/CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 508d33f..1fa813f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -25,7 +25,12 @@ set(VERSION_INFO_MAINT_VERSION git) # Compiler specific setup ######################################################################## -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -W -Wall") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") + +if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANGCC) + add_definitions(-Wall) + add_definitions(-Wno-unused) +endif() ########################################################################