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: windows build fixes
works with cygwin and x86_64-w64-mingw32-gcc/x86_64-w64-mingw32-g++
from the package installer of cygwin.
To use that add the following lines to .bash_profile

export CC=x86_64-w64-mingw32-gcc
export CXX=x86_64-w64-mingw32-g++

you also need cmake from cygwin
  • Loading branch information
ra1nb0w committed Nov 9, 2019
commit 8cd1f87ef61555b45a3fdebd75fe81a999f0b1e6
20 changes: 12 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ add_definitions("-DCOPYRIGHT=\"${COPYRIGHT}\"")
set(IDENTIFIER "com.${COMPANY}.${APPLICATION_NAME}")
add_definitions("-DIDENTIFIER=\"${IDENTIFIER}\"")
# raspberry as only lxterminal not xterm
if(NOT WIN32)
if(NOT (WIN32 OR CYGWIN))
find_program(BINARY_TERMINAL_BIN lxterminal)
if(BINARY_TERMINAL_BIN)
set(APPLICATION_DESKTOP_EXEC "${BINARY_TERMINAL_BIN} -e ${CMAKE_PROJECT_NAME}")
Expand Down Expand Up @@ -86,6 +86,7 @@ if(NOT DEFINED CMAKE_BUILD_TYPE OR "${CMAKE_BUILD_TYPE}" STREQUAL "")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
endif()
message(STATUS "Build type set to: ${CMAKE_BUILD_TYPE}")
message("CMake system: ${CMAKE_SYSTEM_NAME}")

# set compiler
include(FindCompiler)
Expand Down Expand Up @@ -174,12 +175,19 @@ if(LINUX)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_CM108")
endif()

elseif (NOT WIN32)
elseif (NOT WIN32 AND NOT CYGWIN)
find_package(portaudio REQUIRED)
if(PORTAUDIO_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_PORTAUDIO")
endif()

else()
set(ALSA_INCLUDE_DIRS "")
set(ALSA_LIBRARIES "")
set(UDEV_INCLUDE_DIRS "")
set(UDEV_LIBRARIES "")
set(PORTAUDIO_INCLUDE_DIRS "")
set(PORTAUDIO_LIBRARIES "")
endif()

# manage and fetch new data
Expand All @@ -194,13 +202,9 @@ add_subdirectory(${CUSTOM_MISC_DIR})
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()
enable_testing()
add_subdirectory(test)

# manage scripts
add_subdirectory(scripts)
Expand Down
1 change: 1 addition & 0 deletions cmake/modules/FindGPSD.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ else (GPSD_LIBRARIES AND GPSD_INCLUDE_DIRS)

endif (GPSD_LIBRARIES AND GPSD_INCLUDE_DIRS)

# maybe on CYGWIN gpsd works
if (WIN32)
set(GPSD_FOUND FALSE)
set(GPSD_LIBRARIES "")
Expand Down
4 changes: 2 additions & 2 deletions conf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if(LINUX)
string(REGEX REPLACE "\n%W%[^\n]*" "" file_content "${file_content}")
string(REGEX REPLACE "\n%M%[^\n]*" "" file_content "${file_content}")
string(REGEX REPLACE "\n%L%([^\n]*)" "\n\\1" file_content "${file_content}")
elseif(WIN32)
elseif(WIN32 OR CYGWIN)
string(REGEX REPLACE "\n%M%[^\n]*" "" file_content "${file_content}")
string(REGEX REPLACE "\n%L%[^\n]*" "" file_content "${file_content}")
string(REGEX REPLACE "\n%W%([^\n]*)" "\n\\1" file_content "${file_content}")
Expand Down Expand Up @@ -36,7 +36,7 @@ install(FILES "${CUSTOM_CONF_DIR}/sdr.conf" DESTINATION share/doc/${CMAKE_PROJEC
# This step would be done as ordinary user.
# Some people like to put the direwolf config file in /etc/ax25.
# Note that all of these are also in $(DESTDIR)/share/doc/direwolf/examples/.
if(NOT WIN32)
if(NOT (WIN32 OR CYGWIN))
add_custom_target(install-conf
COMMAND ${CMAKE_COMMAND}
-DCUSTOM_BINARY_DIR="${CMAKE_BINARY_DIR}"
Expand Down
4 changes: 2 additions & 2 deletions data/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ ExternalProject_Add(download_symbolsx
TEST_COMMAND ""
)

add_custom_target(data-update)
add_dependencies(data-update data_rename download_tocalls download_symbols-new download_symbolsx)
add_custom_target(update-data)
add_dependencies(update-data data_rename download_tocalls download_symbols-new download_symbolsx)

install(FILES "${CUSTOM_BINARY_DATA_DIR}/${TOCALLS_TXT}" DESTINATION share/${PROJECT_NAME})
install(FILES "${CUSTOM_BINARY_DATA_DIR}/${SYMBOLS-NEW_TXT}" DESTINATION share/${PROJECT_NAME})
Expand Down
5 changes: 2 additions & 3 deletions external/geotranz/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

set(GEOTRANZ_LIBRARIES geotranz CACHE INTERNAL "geotranz")

set(geotranz_SOURCES
${geotranz_SOURCES}
list(APPEND geotranz_SOURCES
error_string.c
mgrs.c
polarst.c
Expand All @@ -13,6 +12,6 @@ set(geotranz_SOURCES
utm.c
)

ADD_LIBRARY(geotranz STATIC
add_library(geotranz STATIC
${geotranz_SOURCES}
)
19 changes: 12 additions & 7 deletions external/misc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@ include_directories(
)

if(LINUX)
set(misc_SOURCES
${misc_SOURCES}
list(APPEND misc_SOURCES
# Provide our own copy of strlcpy and strlcat
# because they are not included with Linux.
${CUSTOM_MISC_DIR}/strlcpy.c
${CUSTOM_MISC_DIR}/strlcat.c
)
ADD_LIBRARY(misc STATIC

add_library(misc STATIC
${misc_SOURCES}
)
elseif(WIN32) # windows
set(misc_SOURCES
${misc_SOURCES}

elseif(WIN32 OR CYGWIN) # windows

list(APPEND misc_SOURCES
# There are several string functions found in Linux
# but not on Windows. Need to provide our own copy.
${CUSTOM_MISC_DIR}/strsep.c
Expand All @@ -27,10 +28,14 @@ elseif(WIN32) # windows
${CUSTOM_MISC_DIR}/strlcpy.c
${CUSTOM_MISC_DIR}/strlcat.c
)
ADD_LIBRARY(misc STATIC

add_library(misc STATIC
${misc_SOURCES}
)

else()

# on macOS, OpenBSD and FreeBSD not misc is necessary
set(MISC_LIBRARIES "" CACHE INTERNAL "")

endif()
15 changes: 9 additions & 6 deletions external/regex/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
set(REGEX_LIBRARIES "" CACHE INTERNAL "")

if(WIN32) # windows
if(WIN32 OR CYGWIN) # windows

set(REGEX_LIBRARIES regex CACHE INTERNAL "regex")

set(regex_SOURCES
${regex_SOURCES}
list(APPEND regex_SOURCES
# When building for Linux, we use regular expression
# functions supplied by the gnu C library.
# For the native WIN32 version, we need to use our own copy.
# These were copied from http://gnuwin32.sourceforge.net/packages/regex.htm
# Consider upgrading from https://www.gnu.org/software/libc/sources.html
#
# check if needed: -Dbool=int -Dtrue=1 -Dfalse=0
${CUSTOM_REGEX_DIR}/regex.c
)
ADD_LIBRARY(regex STATIC

add_library(regex STATIC
${regex_SOURCES}
)

set_target_properties(regex
PROPERTIES COMPILE_FLAGS "-Dbool=int -Dtrue=1 -Dfalse=0 -DUSE_REGEX_STATIC"
)

endif()
2 changes: 1 addition & 1 deletion scripts/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

if(NOT WIN32)
if(NOT (WIN32 OR CYGWIN))
install(PROGRAMS "${CUSTOM_SCRIPTS_DIR}/dwespeak.sh" DESTINATION bin)
install(PROGRAMS "${CUSTOM_SCRIPTS_DIR}/dw-start.sh" DESTINATION share/doc/${CMAKE_PROJECT_NAME}/examples)
add_subdirectory(telemetry-toolkit)
Expand Down
62 changes: 55 additions & 7 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ include_directories(
${CUSTOM_GEOTRANZ_DIR}
)

if(WIN32 OR CYGWIN)
include_directories(
${CUSTOM_REGEX_DIR}
)
endif()

# build gen_fff to create fsk_fast_filter.h
# optimization for slow processors
list(APPEND gen_fff_SOURCES
Expand Down Expand Up @@ -105,17 +111,21 @@ if(LINUX)
cm108.c
)
endif()
elseif(WIN32) # windows
elseif(WIN32 OR CYGWIN) # windows
list(APPEND direwolf_SOURCES
audio_win.c

# icon
${CMAKE_SOURCE_DIR}/cmake/cpack/direwolf.rc
# require plain gcc binary or link
#${CMAKE_SOURCE_DIR}/cmake/cpack/direwolf.rc
)
list(REMOVE_ITEM direwolf_SOURCES
dwgpsd.c
)
else() # macOS freebsd openbsd
list(APPEND direwolf_SOURCES
audio_portaudio.c
)
else() # macOS freebsd openbsd
list(APPEND direwolf_SOURCES
audio_portaudio.c
)
endif()

add_executable(direwolf
Expand All @@ -136,6 +146,13 @@ target_link_libraries(direwolf
${PORTAUDIO_LIBRARIES}
)

if(WIN32 OR CYGWIN)
set_target_properties(direwolf
PROPERTIES COMPILE_FLAGS "-DUSE_REGEX_STATIC"
)
target_link_libraries(direwolf winmm ws2_32)
endif()

# decode_aprs
list(APPEND decode_aprs_SOURCES
decode_aprs.c
Expand All @@ -154,18 +171,25 @@ list(APPEND decode_aprs_SOURCES
tt_text.c
)

if(WIN32 OR CYGWIN)
list(REMOVE_ITEM decode_aprs_SOURCES
dwgpsd.c
)
endif()

add_executable(decode_aprs
${decode_aprs_SOURCES}
)

add_dependencies(decode_aprs gen_fff)

set_target_properties(decode_aprs
PROPERTIES COMPILE_FLAGS "-DDECAMAIN"
PROPERTIES COMPILE_FLAGS "-DDECAMAIN -DUSE_REGEX_STATIC"
)

target_link_libraries(decode_aprs
${MISC_LIBRARIES}
${REGEX_LIBRARIES}
Threads::Threads
${GPSD_LIBRARIES}
)
Expand Down Expand Up @@ -306,6 +330,12 @@ list(APPEND atest_SOURCES
textcolor.c
)

if(WIN32 OR CYGWIN)
list(REMOVE_ITEM atest_SOURCES
dwgpsd.c
)
endif()

add_executable(atest
${atest_SOURCES}
)
Expand All @@ -315,9 +345,16 @@ add_dependencies(atest gen_fff)
target_link_libraries(atest
${MISC_LIBRARIES}
${GPSD_LIBRARIES}
${REGEX_LIBRARIES}
Threads::Threads
)

if(WIN32 OR CYGWIN)
set_target_properties(atest
PROPERTIES COMPILE_FLAGS "-DUSE_REGEX_STATIC"
)
endif()


# Multiple AGWPE network or serial port clients to test TNCs side by side.
# aclients
Expand All @@ -337,6 +374,10 @@ target_link_libraries(aclients
Threads::Threads
)

if(WIN32 OR CYGWIN)
target_link_libraries(aclients ws2_32)
endif()


# Talk to a KISS TNC.
# Note: kiss_frame.c has conditional compilation on KISSUTIL.
Expand Down Expand Up @@ -365,6 +406,10 @@ target_link_libraries(kissutil
Threads::Threads
)

if(WIN32 OR CYGWIN)
target_link_libraries(kissutil ws2_32)
endif()


# List USB audio adapters than can use GPIO for PTT.
# cm108
Expand Down Expand Up @@ -406,6 +451,9 @@ target_link_libraries(ttcalc
${MISC_LIBRARIES}
)

if(WIN32 OR CYGWIN)
target_link_libraries(ttcalc ws2_32)
endif()

install(TARGETS direwolf DESTINATION bin)
install(TARGETS decode_aprs DESTINATION bin)
Expand Down
1 change: 0 additions & 1 deletion src/beacon.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
#include "mheard.h"



/*
* Save pointers to configuration settings.
*/
Expand Down
3 changes: 1 addition & 2 deletions src/direwolf.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@
#define SLEEP_MS(n) usleep((n)*1000)
#endif


#if __WIN32__

#define PTW32_STATIC_LIB
Expand All @@ -124,7 +123,7 @@
#define _POSIX_C_SOURCE 1

#else
#include <pthread.h>
#include <pthread.h>
#endif


Expand Down
1 change: 0 additions & 1 deletion src/dtime_now.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ double dtime_now (void)
}



/*------------------------------------------------------------------
*
* Name: timestamp_now
Expand Down
Loading