Skip to content

Commit

Permalink
cleanup CMakeLists.txt a bit. (GPSBabel#669)
Browse files Browse the repository at this point in the history
add support for cmake, ninja to Docker images.
get git to ignore various generated files.
  • Loading branch information
tsteven4 authored Jan 26, 2021
1 parent 9fbf3e8 commit 100c9c1
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 73 deletions.
14 changes: 9 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,27 @@
/gpsbabel.html
/gpsbabel.pdf
/Makefile
/.qmake.cache
/.qmake.stash
.qmake.cache
.qmake.stash
/GPSBabel
/*.gcda
/*.gcno
/*.gcov
*.o
.ninja_deps
.ninja_log
build.ninja
rules.ninja
cmake_install.cmake
CMakeCache.txt
CMakeFiles/
/GPSBabel[0-9]*.[0-9]*.[0-9]*/
/GPSBabel[0-9]*.[0-9]*.[0-9]*.tar.bz2
/Makefile
/makelinuxdist.sh
/objects/
/release/
*.swp
/tmp/
/Makefile
/Makefile
/mkcapabilities
/gpsbabel.rc
/autogen/
Expand Down
49 changes: 21 additions & 28 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,21 @@
# tested against MSVC 2017 which included 3.11.* 2018/07/05
cmake_minimum_required(VERSION 3.5.1)

project(gpsbabel)
project(gpsbabel LANGUAGES C CXX)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)

# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)

# Find the Qt5Core library
find_package(Qt5 COMPONENTS Core REQUIRED)
message("Qt5Core_VERSION String describing the version of the module: \"${Qt5Core_VERSION}\"")
message("Qt5Core_LIBRARIES List of libraries for use with the target_link_libraries command: \"${Qt5Core_LIBRARIES}\"")
message("Qt5Core_INCLUDE_DIRS List of directories for use with the include_directories command: \"${Qt5Core_INCLUDE_DIRS}\"")
message("Qt5Core_DEFINITIONS List of definitions for use with add_definitions: \"${Qt5Core_DEFINITIONS}\"")
message("Qt5Core_COMPILE_DEFINITIONS List of definitions for use with the COMPILE_DEFINITIONS target property: \"${Qt5Core_COMPILE_DEFINITIONS}\"")
message("Qt5Core_FOUND Boolean describing whether the module was found successfully: \"${Qt5Core_FOUND}\"")
message("Qt5Core_EXECUTABLE_COMPILE_FLAGS String of flags to be used when building executables: \"${Qt5Core_EXECUTABLE_COMPILE_FLAGS}\"")
if (${Qt5Core_VERSION} VERSION_LESS 5.9)
if(${Qt5Core_VERSION} VERSION_LESS 5.9)
message(FATAL_ERROR "Qt version ${Qt5Core_VERSION} found, but version 5.9 or newer is required.")
else()
message(STATUS "Using Qt5 version ${Qt5Core_VERSION}")
endif()
include_directories(AFTER SYSTEM ${Qt5Core_INCLUDE_DIRS})
add_definitions(${Qt5Core_DEFINITIONS})

set(MINIMAL_FMTS
magproto.cc explorist_ini.cc gpx.cc geo.cc mapsend.cc garmin.cc
Expand Down Expand Up @@ -82,7 +76,7 @@ set(ZLIB

set(JEEPS
jeeps/gpsapp.cc jeeps/gpscom.cc
jeeps/gpsmath.cc jeeps/gpsmem.cc
jeeps/gpsmath.cc jeeps/gpsmem.cc
jeeps/gpsprot.cc jeeps/gpsread.cc
jeeps/gpsdevice.cc jeeps/gpsdevice_ser.cc jeeps/gpsdevice_usb.cc
jeeps/gpsrqst.cc jeeps/gpssend.cc jeeps/gpsserial.cc jeeps/jgpsutil.cc
Expand All @@ -98,7 +92,7 @@ set(SUPPORT
gbfile.cc parse.cc session.cc main.cc globals.cc
src/core/textstream.cc
src/core/usasciicodec.cc
src/core/xmlstreamwriter.cc
src/core/xmlstreamwriter.cc
)

set(HEADERS
Expand Down Expand Up @@ -197,15 +191,15 @@ set(HEADERS ${HEADERS} ${FILTER_HEADERS})

include_directories(AFTER zlib)

INCLUDE (CheckIncludeFile)
include(CheckIncludeFile)
if(UNIX)
# this is used by zlib
CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H)
check_include_file("unistd.h" HAVE_UNISTD_H)
if(${HAVE_UNISTD_H})
add_definitions(-DHAVE_UNISTD_H)
endif()
# this is used by zlib
CHECK_INCLUDE_FILE("stdarg.h" HAVE_STDARG_H)
check_include_file("stdarg.h" HAVE_STDARG_H)
if(${HAVE_STDARG_H})
add_definitions(-DHAVE_STDARG_H)
endif()
Expand Down Expand Up @@ -235,11 +229,11 @@ if(MSVC)
add_compile_options(/MP -wd4100 -wd4267)
endif()

if (UNIX AND NOT APPLE)
if(UNIX AND NOT APPLE)
set(LIBS ${LIBS} usb-1.0)
endif()

if (APPLE)
if(APPLE)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lobjc -framework IOKit -framework CoreFoundation")
include_directories(AFTER mac/libusb mac/libusb/Xcode)
set(SOURCES ${SOURCES}
Expand Down Expand Up @@ -277,17 +271,16 @@ add_definitions(-DSHAPELIB_ENABLED)
add_definitions(-DCSVFMTS_ENABLED)

add_executable(gpsbabel ${SOURCES} ${HEADERS})
target_link_libraries(gpsbabel ${Qt5Core_LIBRARIES} ${LIBS})
target_link_libraries(gpsbabel Qt5::Core ${LIBS})

message("Sources are:")
message("${SOURCES}")
message("Headers are:")
message("${HEADERS}")
message("Defines are:")
get_directory_property( DirDefs COMPILE_DEFINITIONS)
message("${DirDefs}")
message("Libs are:")
message("${LIBS}")
message(STATUS "Sources are: \"${SOURCES}\"")
message(STATUS "Headers are: \"${HEADERS}\"")
get_directory_property(DirDefs COMPILE_DEFINITIONS)
message(STATUS "Defines are: \"${DirDefs}\"")
get_target_property(LnkLibs gpsbabel LINK_LIBRARIES)
message(STATUS "Libs are: \"${LnkLibs}\"")
get_directory_property(IncDirs INCLUDE_DIRECTORIES)
message(STATUS "Include Directores are: \"${IncDirs}\"")

if(UNIX)
# the tests only work if the pwd is top level source dir due to the file name getting embedded in the file nonexistent.err.
Expand Down
1 change: 1 addition & 0 deletions gui/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/GPSBabel[0-9]*.[0-9]*.[0-9]*.tar.bz2
/GPSBabelFE/
/GPSBabelFE.app/
/gpsbabelfe_autogen/
/Makefile
/objects/
/tmp/
Expand Down
64 changes: 24 additions & 40 deletions gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
# tested against MSVC 2017 which included 3.11.* 2018/07/05
cmake_minimum_required(VERSION 3.5.1)

project(gpsbabelfe)
project(gpsbabelfe LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)

# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
Expand All @@ -19,56 +20,39 @@ set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)

# Find the Qt5Core library
find_package(Qt5 COMPONENTS Core Gui Network Xml REQUIRED)
#message("Qt5Core_VERSION String describing the version of the module: \"${Qt5Core_VERSION}\"")
#message("Qt5Core_LIBRARIES List of libraries for use with the target_link_libraries command: \"${Qt5Core_LIBRARIES}\"")
#message("Qt5Core_INCLUDE_DIRS List of directories for use with the include_directories command: \"${Qt5Core_INCLUDE_DIRS}\"")
#message("Qt5Core_DEFINITIONS List of definitions for use with add_definitions: \"${Qt5Core_DEFINITIONS}\"")
#message("Qt5Core_COMPILE_DEFINITIONS List of definitions for use with the COMPILE_DEFINITIONS target property: \"${Qt5Core_COMPILE_DEFINITIONS}\"")
#message("Qt5Core_FOUND Boolean describing whether the module was found successfully: \"${Qt5Core_FOUND}\"")
#message("Qt5Core_EXECUTABLE_COMPILE_FLAGS String of flags to be used when building executables: \"${Qt5Core_EXECUTABLE_COMPILE_FLAGS}\"")
if (${Qt5Core_VERSION} VERSION_LESS 5.9)
find_package(Qt5 COMPONENTS Core Gui Network Widgets Xml REQUIRED)
list(APPEND QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::Network Qt5::Widgets Qt5::Xml)
if(${Qt5Core_VERSION} VERSION_LESS 5.9)
message(FATAL_ERROR "Qt version ${Qt5Core_VERSION} found, but version 5.9 or newer is required.")
else()
message(STATUS "Using Qt5 version ${Qt5Core_VERSION}")
endif()

# hard code webengine instead of webkit for now
find_package(Qt5 COMPONENTS WebEngineWidgets WebChannel REQUIRED)
list(APPEND QT_LIBRARIES Qt5::WebEngineWidgets Qt5::WebChannel)
add_definitions(-DHAVE_WEBENGINE)

set(QT_INCLUDE_DIRS ${Qt5Core_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS} ${Qt5Xml_INCLUDE_DIRS} ${Qt5WebEngineWidgets_INCLUDE_DIRS} ${Qt5WebChannel_INCLUDE_DIRS})
list(REMOVE_DUPLICATES QT_INCLUDE_DIRS)
message("QT INCLUDE DIRS: \"${QT_INCLUDE_DIRS}\"\n")

set(QT_DEFINITIONS ${Qt5Core_DEFINITIONS} ${QT5Gui_DEFINITIONS} ${Qt5Network_DEFINITIONS} ${Qt5Xml_DEFINITIONS} ${Qt5WebEngineWidgets_DEFINITIONS} ${Qt5WwebChannel_DEFINITIONS})
list(REMOVE_DUPLICATES QT_DEFINITIONS)
message("QT DEFS: \"${QT_DEFINITIONS}\"\n")

set(QT_LIBRARIES ${Qt5Core_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Xml_LIBRARIES} ${Qt5WebEngineWidgets_LIBRARIES} ${Qt5WebChannel_LIBRARIES})
#list(REMOVE_DUPLICATES QT_LIBRARIES)
message("QT LIBS: \"${QT_LIBRARIES}\"\n")

include_directories(AFTER SYSTEM ${QT_INCLUDE_DIRS})
add_definitions(${QT_DEFINITIONS} -DHAVE_WEBENGINE)

if (APPLE)
if(APPLE)
find_library(IOKIT_LIBRARIES IOKit)
find_library(COREFOUNDATION_LIBRARIES CoreFoundation)
endif()

if (UNIX AND NOT APPLE)
if(UNIX AND NOT APPLE)
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBUDEV libudev)
if (${LIBUDEV_FOUND})
if(${LIBUDEV_FOUND})
add_definitions(-DHAVE_UDEV)
endif()
endif()

set(RESOURCES app.qrc)

if (WIN32)
if(WIN32)
set(RESOURCES ${RESOURCES} app.rc)
endif()

if (UNIX AND NOT APPLE)
if(UNIX AND NOT APPLE)
set(TARGET gpsbabelfe)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY GPSBabelFE)
else()
Expand Down Expand Up @@ -115,11 +99,11 @@ set(SOURCES
version_mismatch.cc
)

if (UNIX AND NOT APPLE)
if(UNIX AND NOT APPLE)
set(SOURCES ${SOURCES} serial_unix.cc)
elseif (APPLE)
elseif(APPLE)
set(SOURCES ${SOURCES} serial_mac.cc)
elseif (WIN32)
elseif(WIN32)
set(SOURCES ${SOURCES} serial_win.cc)
endif()

Expand Down Expand Up @@ -147,7 +131,7 @@ set(HEADERS
version_mismatch.h
)

if (APPLE)
if(APPLE)
set(MACOSX_BUNDLE_ICON_FILE appicon.icns)
set(ICON_FILE images/${MACOSX_BUNDLE_ICON_FILE})
set_source_files_properties(${ICON_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
Expand All @@ -167,13 +151,13 @@ set(LIBS ${QT_LIBRARIES} ${LIBUDEV_LIBRARIES} ${IOKIT_LIBRARIES} ${COREFOUNDATIO
list(REMOVE_DUPLICATES LIBS)
target_link_libraries(${TARGET} ${LIBS})

message("Sources are: \"${SOURCES}\"\n")
message("Headers are: \"${HEADERS}\"\n")
message(STATUS "Sources are: \"${SOURCES}\"")
message(STATUS "Headers are: \"${HEADERS}\"")
get_directory_property(DirDefs COMPILE_DEFINITIONS)
message("Defines are: \"${DirDefs}\"\n")
message(STATUS "Defines are: \"${DirDefs}\"")
get_target_property(LnkLibs ${TARGET} LINK_LIBRARIES)
message("Libs are: \"${LnkLibs}\"\n")
message(STATUS "Libs are: \"${LnkLibs}\"")
get_directory_property(IncDirs INCLUDE_DIRECTORIES)
message("Include Directores are: \"${IncDirs}\"\n")
message(STATUS "Include Directores are: \"${IncDirs}\"")

add_custom_target(package COMMAND ./package_app DEPENDS ${TARGET})
add_custom_target(package_app COMMAND ./package_app DEPENDS ${TARGET})
2 changes: 2 additions & 0 deletions tools/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
expat \
libxml2-utils \
bear \
cmake \
ninja-build \
&& rm -rf /var/lib/apt/lists/*

# alternative compiler
Expand Down
2 changes: 2 additions & 0 deletions tools/Dockerfile_focal
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
expat \
libxml2-utils \
bear \
cmake \
ninja-build \
clazy \
&& rm -rf /var/lib/apt/lists/*

Expand Down
2 changes: 2 additions & 0 deletions tools/Dockerfile_qtio
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
expat \
libxml2-utils \
bear \
cmake \
ninja-build \
&& rm -rf /var/lib/apt/lists/*

# alternative compiler
Expand Down

0 comments on commit 100c9c1

Please sign in to comment.