Skip to content

move to cmake, ctest, cpack to build direwolf #227

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Nov 23, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
cmake: implements tests using CTest suite
the new tests are implemented with CTest suite of CMake.
To enable the tests you need to run cmake with -DBUILD_TESTING=ON
There are optional tests (that might not work) that can be enabled with
-DOPTIONAL_TEST=ON

So, to enable all tests and run it use the following command

mkdir build
cmake -DBUILD_TESTING=ON -DOPTIONA_TEST=ON ..
make
ctest

to debug the errors use

ctest --debug

You can always find all tests binary on build/test/

Implementation:
- check-modem* tests are implemented with shell script because it
  requires to execute many commands and therefore will be easy to
  manage. The file is configured at configuration time.
- for single binary we verify the exit status (default = 0) so you
  only need to build the binary and add it to add_test()
  • Loading branch information
ra1nb0w committed Nov 9, 2019
commit 0e5049c08ad154f2365a288397081ed829a416ab
21 changes: 16 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# TODO:
# - check which MSVC are compatible
# - cpack
# - ctest

cmake_minimum_required(VERSION 3.1.0)

project(direwolf)
Expand All @@ -17,6 +12,7 @@ set(direwolf_VERSION_SUFFIX "")
option(FORCE_SSE "Compile with SSE instruction only" OFF)
option(FORCE_SSSE3 "Compile with SSSE3 instruction only" OFF)
option(FORCE_SSE41 "Compile with SSE4.1 instruction only" OFF)
option(OPTIONAL_TEST "Compile optional test (might be broken)" OFF)

# where cmake find custom modules
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
Expand Down Expand Up @@ -70,6 +66,7 @@ if(direwolf_VERSION_COMMIT)
add_definitions("-DEXTRA_VERSION=${direwolf_VERSION_COMMIT}")
endif()

set(CUSTOM_SRC_DIR "${CMAKE_SOURCE_DIR}/src")
set(CUSTOM_EXTERNAL_DIR "${CMAKE_SOURCE_DIR}/external")
set(CUSTOM_MISC_DIR "${CUSTOM_EXTERNAL_DIR}/misc")
set(CUSTOM_REGEX_DIR "${CUSTOM_EXTERNAL_DIR}/regex")
Expand All @@ -80,6 +77,9 @@ set(CUSTOM_TELEMETRY_DIR "${CUSTOM_SCRIPTS_DIR}/telemetry-toolkit")
set(CUSTOM_CONF_DIR "${CMAKE_SOURCE_DIR}/conf")
set(CUSTOM_DOC_DIR "${CMAKE_SOURCE_DIR}/doc")
set(CUSTOM_MAN_DIR "${CMAKE_SOURCE_DIR}/man")
set(CUSTOM_TEST_DIR "${CMAKE_SOURCE_DIR}/test")
set(CUSTOM_TEST_SCRIPTS_DIR "${CUSTOM_TEST_DIR}/scripts")
set(CUSTOM_SHELL_SHABANG "#!/bin/sh -e")

# if we don't set build_type
if(NOT DEFINED CMAKE_BUILD_TYPE OR "${CMAKE_BUILD_TYPE}" STREQUAL "")
Expand Down Expand Up @@ -124,6 +124,8 @@ elseif (WIN32)
# compile with full multicore
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")

set(CUSTOM_SHELL_BIN "")
endif()

if (C_CLANG OR C_GCC)
Expand Down Expand Up @@ -191,6 +193,15 @@ add_subdirectory(${CUSTOM_MISC_DIR})
# direwolf source code and utilities
add_subdirectory(src)

# ctest
# Note CMake will generate tests only if the enable_testing() command
# has been invoked. The CTest module invokes the command automatically
# when the BUILD_TESTING option is ON.
include(CTest)
if(BUILD_TESTING)
add_subdirectory(test)
endif()

# manage scripts
add_subdirectory(scripts)

Expand Down
83 changes: 26 additions & 57 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# global includes
# not ideal but not so slow
# otherwise use target_include_directories
include_directories(
${GPSD_INCLUDE_DIRS}
${HAMLIB_INCLUDE_DIRS}
Expand All @@ -11,8 +12,7 @@ include_directories(

# build gen_fff to create fsk_fast_filter.h
# optimization for slow processors
set(gen_fff_SOURCES
${gen_fff_SOURCES}
list(APPEND gen_fff_SOURCES
demod_afsk.c
dsp.c
textcolor.c
Expand All @@ -32,9 +32,9 @@ add_custom_command(TARGET gen_fff
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)


# direwolf
set(direwolf_SOURCES
${direwolf_SOURCES}
list(APPEND direwolf_SOURCES
direwolf.c
aprs_tt.c
audio_stats.c
Expand Down Expand Up @@ -97,29 +97,25 @@ set(direwolf_SOURCES
)

if(LINUX)
set(direwolf_SOURCES
${direwolf_SOURCES}
list(APPEND direwolf_SOURCES
audio.c
)
if(UDEV_FOUND)
set(direwolf_SOURCES
${direwolf_SOURCES}
list(APPEND direwolf_SOURCES
cm108.c
)
endif()
elseif(WIN32) # windows
set(direwolf_SOURCES
${direwolf_SOURCES}
audio_win.c
list(APPEND direwolf_SOURCES
audio_win.c

# icon
${CMAKE_SOURCE_DIR}/cmake/cpack/direwolf.rc
)
# icon
${CMAKE_SOURCE_DIR}/cmake/cpack/direwolf.rc
)
else() # macOS freebsd openbsd
set(direwolf_SOURCES
${direwolf_SOURCES}
audio_portaudio.c
)
list(APPEND direwolf_SOURCES
audio_portaudio.c
)
endif()

add_executable(direwolf
Expand All @@ -141,8 +137,7 @@ target_link_libraries(direwolf
)

# decode_aprs
set(decode_aprs_SOURCES
${decode_aprs_SOURCES}
list(APPEND decode_aprs_SOURCES
decode_aprs.c
kiss_frame.c
ax25_pad.c
Expand Down Expand Up @@ -178,8 +173,7 @@ target_link_libraries(decode_aprs

# Convert between text and touch tone representation.
# text2tt
set(text2tt_SOURCES
${text2tt_SOURCES}
list(APPEND text2tt_SOURCES
tt_text.c
)

Expand All @@ -196,8 +190,7 @@ target_link_libraries(text2tt
)

# tt2text
set(tt2text_SOURCES
${tt2text_SOURCES}
list(APPEND tt2text_SOURCES
tt_text.c
)

Expand All @@ -216,8 +209,7 @@ target_link_libraries(tt2text

# Convert between Latitude/Longitude and UTM coordinates.
# ll2utm
set(ll2utm_SOURCES
${ll2utm_SOURCES}
list(APPEND ll2utm_SOURCES
ll2utm.c
textcolor.c
)
Expand All @@ -232,8 +224,7 @@ target_link_libraries(ll2utm
)

# utm2ll
set(utm2ll_SOURCES
${utm2ll_SOURCES}
list(APPEND utm2ll_SOURCES
utm2ll.c
textcolor.c
)
Expand All @@ -250,8 +241,7 @@ target_link_libraries(utm2ll

# Convert from log file to GPX.
# log2gpx
set(log2gpx_SOURCES
${log2gpx_SOURCES}
list(APPEND log2gpx_SOURCES
log2gpx.c
textcolor.c
)
Expand All @@ -267,8 +257,7 @@ target_link_libraries(log2gpx

# Test application to generate sound.
# gen_packets
set(gen_packets_SOURCES
${gen_packets_SOURCES}
list(APPEND gen_packets_SOURCES
gen_packets.c
ax25_pad.c
hdlc_send.c
Expand All @@ -291,8 +280,7 @@ target_link_libraries(gen_packets

# Unit test for AFSK demodulator
# atest
set(atest_SOURCES
${atest_SOURCES}
list(APPEND atest_SOURCES
atest.c
demod.c
demod_afsk.c
Expand Down Expand Up @@ -333,8 +321,7 @@ target_link_libraries(atest

# Multiple AGWPE network or serial port clients to test TNCs side by side.
# aclients
set(aclients_SOURCES
${aclients_SOURCES}
list(APPEND aclients_SOURCES
aclients.c
ax25_pad.c
fcs_calc.c
Expand All @@ -354,8 +341,7 @@ target_link_libraries(aclients
# Talk to a KISS TNC.
# Note: kiss_frame.c has conditional compilation on KISSUTIL.
# kissutil
set(kissutil_SOURCES
${kissutil_SOURCES}
list(APPEND kissutil_SOURCES
kissutil.c
kiss_frame.c
ax25_pad.c
Expand Down Expand Up @@ -383,8 +369,7 @@ target_link_libraries(kissutil
# List USB audio adapters than can use GPIO for PTT.
# cm108
if(UDEV_FOUND)
set(cm108_SOURCES
${cm108_SOURCES}
list(APPEND cm108_SOURCES
cm108.c
textcolor.c
)
Expand All @@ -406,8 +391,7 @@ endif()

# Touch Tone to Speech sample application.
# ttcalc
set(ttcalc_SOURCES
${ttcalc_SOURCES}
list(APPEND ttcalc_SOURCES
ttcalc.c
ax25_pad.c
fcs_calc.c
Expand Down Expand Up @@ -438,18 +422,3 @@ install(TARGETS kissutil DESTINATION bin)
if(UDEV_FOUND)
install(TARGETS cm108 DESTINATION bin)
endif()



## TESTS
# Note CMake will generate tests only if the enable_testing() command
# has been invoked. The CTest module invokes the command automatically
# when the BUILD_TESTING option is ON.
include(CTest)
if(BUILD_TESTING)
# add_test(NAME <name> COMMAND <command> [<arg>...]
# [CONFIGURATIONS <config>...]
# [WORKING_DIRECTORY <dir>])


endif()
Loading