improved project files
This commit is contained in:
parent
cf23e11c93
commit
8feb7e1540
|
@ -1,42 +1,101 @@
|
||||||
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
|
||||||
|
|
||||||
|
# add project files
|
||||||
|
set(HEADER_FILES
|
||||||
|
angle.h
|
||||||
|
location.h
|
||||||
|
main.h
|
||||||
|
utils.h
|
||||||
|
)
|
||||||
|
set(SRC_FILES
|
||||||
|
angle.cpp
|
||||||
|
location.cpp
|
||||||
|
main.cpp
|
||||||
|
utils.cpp
|
||||||
|
)
|
||||||
|
|
||||||
# meta data
|
# meta data
|
||||||
set(META_PROJECT_NAME geocoordinatecalculator)
|
set(META_PROJECT_NAME geocoordinatecalculator)
|
||||||
set(META_APP_NAME "geocoordinatecalculator")
|
set(META_APP_NAME "Geo coordinate calculator")
|
||||||
set(META_APP_AUTHOR "Martchus")
|
set(META_APP_AUTHOR "Martchus")
|
||||||
set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}")
|
set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}")
|
||||||
set(META APP_DESCRIPTION "Command line tool for basic calculations with geo coordinates such as format conversions and calculation of distance, bearing, mid point, destination and more.")
|
set(META_APP_DESCRIPTION "Command line tool for basic calculations with geo coordinates such as format conversions and calculation of distance, bearing, mid point, destination and more.")
|
||||||
set(META_VERSION_MAJOR 1)
|
set(META_VERSION_MAJOR 1)
|
||||||
set(META_VERSION_MINOR 0)
|
set(META_VERSION_MINOR 0)
|
||||||
set(META_VERSION_PATCH 1)
|
set(META_VERSION_PATCH 1)
|
||||||
|
set(META_APP_VERSION ${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH})
|
||||||
# define project
|
|
||||||
project(${META_PROJECT_NAME})
|
|
||||||
|
|
||||||
# stringification of meta data
|
# stringification of meta data
|
||||||
set(META_PROJECT_NAME_STR "\"${META_PROJECT_NAME}\"")
|
set(META_PROJECT_NAME_STR "\"${META_PROJECT_NAME}\"")
|
||||||
set(META_APP_NAME_STR "\"${META_APP_NAME}\"")
|
set(META_APP_NAME_STR "\"${META_APP_NAME}\"")
|
||||||
set(META_APP_AUTHOR_STR "\"${META_APP_AUTHOR}\"")
|
set(META_APP_AUTHOR_STR "\"${META_APP_AUTHOR}\"")
|
||||||
set(META_APP_URL_STR "\"${META_APP_URL}\"")
|
set(META_APP_URL_STR "\"${META_APP_URL}\"")
|
||||||
set(APP_DESCRIPTION_STR "\"${APP_DESCRIPTION}\"")
|
set(META_APP_DESCRIPTION_STR "\"${META_APP_DESCRIPTION}\"")
|
||||||
set(META_APP_VERSION_STR "\"${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH}\"")
|
set(META_APP_VERSION ${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH})
|
||||||
|
set(META_APP_VERSION_STR "\"${META_APP_VERSION}\"")
|
||||||
|
|
||||||
|
# define project
|
||||||
|
project(${META_PROJECT_NAME})
|
||||||
|
|
||||||
# add configuration header
|
# add configuration header
|
||||||
configure_file (
|
configure_file(
|
||||||
"${PROJECT_SOURCE_DIR}/config.h.in"
|
"${PROJECT_SOURCE_DIR}/resources/config.h.in"
|
||||||
"${PROJECT_BINARY_DIR}/config.h"
|
"${PROJECT_BINARY_DIR}/resources/config.h"
|
||||||
)
|
)
|
||||||
include_directories("${PROJECT_BINARY_DIR}")
|
include_directories("${PROJECT_BINARY_DIR}")
|
||||||
|
|
||||||
# add source and header files
|
# add windows resource file
|
||||||
file(GLOB PROJ_FILES "*.h" "*.cpp" "*.c")
|
if(MINGW)
|
||||||
|
# creation windows icon from png with ffmpeg if available
|
||||||
|
find_program(FFMPEG_BIN ffmpeg avconv)
|
||||||
|
if(FFMPEG_BIN)
|
||||||
|
set(PNG_ICON_PATH "${PROJECT_SOURCE_DIR}/resources/icons/hicolor/128x128/apps/${META_PROJECT_NAME}.png")
|
||||||
|
if(EXISTS ${PNG_ICON_PATH})
|
||||||
|
set(WINDOWS_ICON_PATH "${PROJECT_BINARY_DIR}/${META_PROJECT_NAME}.ico")
|
||||||
|
set(WINDOWS_ICON_RC_ENTRY "IDI_ICON1 ICON DISCARDABLE \"${WINDOWS_ICON_PATH}\"")
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT "${WINDOWS_ICON_PATH}"
|
||||||
|
COMMAND ${FFMPEG_BIN} -y -i "${PNG_ICON_PATH}" -vf crop=iw-20:ih-20:10:10,scale=64:64 "${WINDOWS_ICON_PATH}"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endif(FFMPEG_BIN)
|
||||||
|
# create windows rc file from template
|
||||||
|
set(WINDOWS_EXT "exe")
|
||||||
|
configure_file(
|
||||||
|
"${PROJECT_SOURCE_DIR}/resources/windows.rc.in"
|
||||||
|
"${PROJECT_BINARY_DIR}/resources/windows.rc"
|
||||||
|
)
|
||||||
|
# set windres as resource compiler
|
||||||
|
set(RES_FILES "${PROJECT_BINARY_DIR}/resources/windows.rc")
|
||||||
|
set(CMAKE_RC_COMPILER_INIT windres)
|
||||||
|
set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
|
||||||
|
enable_language(RC)
|
||||||
|
endif(MINGW)
|
||||||
|
|
||||||
# executable and linking
|
# executable and linking
|
||||||
add_executable(${META_PROJECT_NAME} ${PROJ_FILES})
|
add_executable(${META_PROJECT_NAME} ${HEADER_FILES} ${SRC_FILES} ${RES_FILES} ${WINDOWS_ICON_PATH})
|
||||||
target_link_libraries(${META_PROJECT_NAME} c++utilities)
|
target_link_libraries(${META_PROJECT_NAME} c++utilities)
|
||||||
|
set_target_properties(${META_PROJECT_NAME} PROPERTIES
|
||||||
# enable C++11
|
CXX_STANDARD 11
|
||||||
set_property(TARGET ${META_PROJECT_NAME} PROPERTY CXX_STANDARD 11)
|
)
|
||||||
|
|
||||||
# add install target
|
# add install target
|
||||||
install(TARGETS ${META_PROJECT_NAME} DESTINATION bin)
|
install(TARGETS ${META_PROJECT_NAME}
|
||||||
|
RUNTIME DESTINATION bin
|
||||||
|
COMPONENT binary
|
||||||
|
)
|
||||||
|
add_custom_target(install-binary
|
||||||
|
DEPENDS ${META_PROJECT_NAME}
|
||||||
|
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=binary -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
|
||||||
|
)
|
||||||
|
add_custom_target(install-mingw-w64
|
||||||
|
DEPENDS install-binary
|
||||||
|
)
|
||||||
|
add_custom_target(install-binary-strip
|
||||||
|
DEPENDS ${META_PROJECT_NAME}
|
||||||
|
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_DO_STRIP=1 -DCMAKE_INSTALL_COMPONENT=binary -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
|
||||||
|
)
|
||||||
|
add_custom_target(install-mingw-w64-strip
|
||||||
|
DEPENDS install-binary-strip
|
||||||
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
#ifndef APP_METADATA_AVAIL
|
|
||||||
#define APP_METADATA_AVAIL
|
|
||||||
#define PROJECT_NAME @META_PROJECT_NAME_STR@
|
|
||||||
#define APP_NAME @META_APP_NAME_STR@
|
|
||||||
#define APP_VERSION @META_APP_VERSION_STR@
|
|
||||||
#define APP_AUTHOR @META_APP_AUTHOR_STR@
|
|
||||||
#define APP_URL @META_APP_URL_STR@
|
|
||||||
#define APP_DESCRIPTION @META_APP_DESCRIPTION_STR@
|
|
||||||
#endif // APP_METADATA_AVAIL
|
|
56
general.pri
56
general.pri
|
@ -1,28 +1,12 @@
|
||||||
#dirs
|
# specify build directories for moc, object and rcc files
|
||||||
MOC_DIR = ./moc
|
MOC_DIR = ./moc
|
||||||
OBJECTS_DIR = ./obj
|
OBJECTS_DIR = ./obj
|
||||||
RCC_DIR = ./res
|
RCC_DIR = ./res
|
||||||
# compiler flags
|
|
||||||
|
# compiler flags: enable C++11
|
||||||
QMAKE_CXXFLAGS += -std=c++11
|
QMAKE_CXXFLAGS += -std=c++11
|
||||||
QMAKE_LFLAGS += -std=c++11
|
QMAKE_LFLAGS += -std=c++11
|
||||||
# prefix
|
|
||||||
targetprefix = $$(TARGET_PREFIX)
|
|
||||||
message("Using target prefix \"$${targetprefix}\".")
|
|
||||||
# print install root
|
|
||||||
message("Using install root \"$$(INSTALL_ROOT)\".")
|
|
||||||
# target
|
|
||||||
CONFIG(debug, debug|release) {
|
|
||||||
TARGET = $${targetprefix}$${projectname}d
|
|
||||||
} else {
|
|
||||||
TARGET = $${targetprefix}$${projectname}
|
|
||||||
}
|
|
||||||
# add defines
|
|
||||||
DEFINES += "APP_METADATA_AVAIL"
|
|
||||||
DEFINES += "'PROJECT_NAME=\"$${projectname}\"'"
|
|
||||||
DEFINES += "'APP_NAME=\"$${appname}\"'"
|
|
||||||
DEFINES += "'APP_AUTHOR=\"$${appauthor}\"'"
|
|
||||||
DEFINES += "'APP_URL=\"$${appurl}\"'"
|
|
||||||
DEFINES += "'APP_VERSION=\"$${VERSION}\"'"
|
|
||||||
# variables to check target architecture
|
# variables to check target architecture
|
||||||
win32-g++:QMAKE_TARGET.arch = $$QMAKE_HOST.arch
|
win32-g++:QMAKE_TARGET.arch = $$QMAKE_HOST.arch
|
||||||
win32-g++-32:QMAKE_TARGET.arch = x86
|
win32-g++-32:QMAKE_TARGET.arch = x86
|
||||||
|
@ -30,7 +14,30 @@ win32-g++-64:QMAKE_TARGET.arch = x86_64
|
||||||
linux-g++:QMAKE_TARGET.arch = $$QMAKE_HOST.arch
|
linux-g++:QMAKE_TARGET.arch = $$QMAKE_HOST.arch
|
||||||
linux-g++-32:QMAKE_TARGET.arch = x86
|
linux-g++-32:QMAKE_TARGET.arch = x86
|
||||||
linux-g++-64:QMAKE_TARGET.arch = x86_64
|
linux-g++-64:QMAKE_TARGET.arch = x86_64
|
||||||
# configuration
|
|
||||||
|
# determine and print target prefix
|
||||||
|
targetprefix = $$(TARGET_PREFIX)
|
||||||
|
message("Using target prefix \"$${targetprefix}\".")
|
||||||
|
|
||||||
|
# print install root
|
||||||
|
message("Using install root \"$$(INSTALL_ROOT)\".")
|
||||||
|
|
||||||
|
# set target
|
||||||
|
CONFIG(debug, debug|release) {
|
||||||
|
TARGET = $${targetprefix}$${projectname}d
|
||||||
|
} else {
|
||||||
|
TARGET = $${targetprefix}$${projectname}
|
||||||
|
}
|
||||||
|
|
||||||
|
# add defines for meta data
|
||||||
|
DEFINES += "APP_METADATA_AVAIL"
|
||||||
|
DEFINES += "'PROJECT_NAME=\"$${projectname}\"'"
|
||||||
|
DEFINES += "'APP_NAME=\"$${appname}\"'"
|
||||||
|
DEFINES += "'APP_AUTHOR=\"$${appauthor}\"'"
|
||||||
|
DEFINES += "'APP_URL=\"$${appurl}\"'"
|
||||||
|
DEFINES += "'APP_VERSION=\"$${VERSION}\"'"
|
||||||
|
|
||||||
|
# configure Qt modules and defines
|
||||||
mobile {
|
mobile {
|
||||||
DEFINES += CONFIG_MOBILE
|
DEFINES += CONFIG_MOBILE
|
||||||
} else:desktop {
|
} else:desktop {
|
||||||
|
@ -61,7 +68,7 @@ no-gui {
|
||||||
}
|
}
|
||||||
guiqtquick {
|
guiqtquick {
|
||||||
message("Configured for Qt Quick GUI support.")
|
message("Configured for Qt Quick GUI support.")
|
||||||
greaterThan(QT_MAJOR_VERSION, 4): QT += quick
|
QT += quick
|
||||||
CONFIG(debug, debug|release) {
|
CONFIG(debug, debug|release) {
|
||||||
CONFIG += qml_debug
|
CONFIG += qml_debug
|
||||||
}
|
}
|
||||||
|
@ -69,11 +76,12 @@ guiqtquick {
|
||||||
}
|
}
|
||||||
guiqtwidgets {
|
guiqtwidgets {
|
||||||
message("Configured for Qt widgets GUI support.")
|
message("Configured for Qt widgets GUI support.")
|
||||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
QT += widgets
|
||||||
DEFINES += GUI_QTWIDGETS
|
DEFINES += GUI_QTWIDGETS
|
||||||
DEFINES += MODEL_UNDO_SUPPORT
|
DEFINES += MODEL_UNDO_SUPPORT
|
||||||
}
|
}
|
||||||
# Windows stuff: configuration for cross compliation with mingw-w64
|
|
||||||
|
# configuration for cross compliation with mingw-w64
|
||||||
win32 {
|
win32 {
|
||||||
QMAKE_TARGET_PRODUCT = "$${appname}"
|
QMAKE_TARGET_PRODUCT = "$${appname}"
|
||||||
QMAKE_TARGET_COPYRIGHT = "by $${appauthor}"
|
QMAKE_TARGET_COPYRIGHT = "by $${appauthor}"
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
# meta data
|
||||||
projectname = geocoordinatecalculator
|
projectname = geocoordinatecalculator
|
||||||
appname = "Geo coordinate calculator"
|
appname = "Geo coordinate calculator"
|
||||||
appauthor = Martchus
|
appauthor = Martchus
|
||||||
|
@ -5,6 +6,7 @@ appurl = "https://github.com/$${appauthor}/$${projectname}"
|
||||||
QMAKE_TARGET_DESCRIPTION = "Command line tool for basic calculations with geo coordinates such as format conversions and calculation of distance, bearing, mid point, destination and more."
|
QMAKE_TARGET_DESCRIPTION = "Command line tool for basic calculations with geo coordinates such as format conversions and calculation of distance, bearing, mid point, destination and more."
|
||||||
VERSION = 1.0.1
|
VERSION = 1.0.1
|
||||||
|
|
||||||
|
# implicit configuration: no GUI
|
||||||
CONFIG += no-gui
|
CONFIG += no-gui
|
||||||
|
|
||||||
# include ../../common.pri when building as part of a subdirs project; otherwise include general.pri
|
# include ../../common.pri when building as part of a subdirs project; otherwise include general.pri
|
||||||
|
@ -14,28 +16,32 @@ CONFIG += no-gui
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# basic configuration: console application, no Qt
|
||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
|
|
||||||
CONFIG -= qt
|
CONFIG -= qt
|
||||||
CONFIG += console
|
CONFIG += console
|
||||||
|
|
||||||
SOURCES += main.cpp \
|
# add project files
|
||||||
location.cpp \
|
|
||||||
angle.cpp \
|
|
||||||
utils.cpp
|
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
main.h \
|
main.h \
|
||||||
location.h \
|
location.h \
|
||||||
angle.h \
|
angle.h \
|
||||||
utils.h
|
utils.h
|
||||||
|
|
||||||
RESOURCES += images.qrc
|
SOURCES += \
|
||||||
|
main.cpp \
|
||||||
|
location.cpp \
|
||||||
|
angle.cpp \
|
||||||
|
utils.cpp
|
||||||
|
|
||||||
OTHER_FILES += \
|
OTHER_FILES += \
|
||||||
README.md \
|
README.md \
|
||||||
LICENSE
|
LICENSE \
|
||||||
|
CMakeLists.txt \
|
||||||
|
resources/config.h.in \
|
||||||
|
resources/windows.rc.in
|
||||||
|
|
||||||
|
# add libs
|
||||||
CONFIG(debug, debug|release) {
|
CONFIG(debug, debug|release) {
|
||||||
LIBS += -lc++utilitiesd
|
LIBS += -lc++utilitiesd
|
||||||
} else {
|
} else {
|
||||||
|
|
2
main.cpp
2
main.cpp
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
// include configuration from separate header file when building with CMake
|
// include configuration from separate header file when building with CMake
|
||||||
#ifndef APP_METADATA_AVAIL
|
#ifndef APP_METADATA_AVAIL
|
||||||
#include "config.h"
|
#include "resources/config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <c++utilities/application/argumentparser.h>
|
#include <c++utilities/application/argumentparser.h>
|
||||||
|
|
Loading…
Reference in New Issue