improved project files
This commit is contained in:
parent
47b96df17b
commit
fd52756e1d
143
CMakeLists.txt
143
CMakeLists.txt
|
@ -1,53 +1,156 @@
|
|||
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
|
||||
|
||||
# add project files
|
||||
set(HEADER_FILES
|
||||
application/argumentparser.h
|
||||
application/commandlineutils.h
|
||||
application/failure.h
|
||||
application/fakeqtconfigarguments.h
|
||||
application/global.h
|
||||
chrono/datetime.h
|
||||
chrono/period.h
|
||||
chrono/timespan.h
|
||||
conversion/binaryconversion.h
|
||||
conversion/binaryconversionprivate.h
|
||||
conversion/conversionexception.h
|
||||
conversion/stringconversion.h
|
||||
conversion/types.h
|
||||
conversion/widen.h
|
||||
io/ansiescapecodes.h
|
||||
io/binaryreader.h
|
||||
io/binarywriter.h
|
||||
io/bitreader.h
|
||||
io/copy.h
|
||||
io/inifile.h
|
||||
io/path.h
|
||||
math/math.h
|
||||
misc/memory.h
|
||||
misc/random.h
|
||||
)
|
||||
set(SRC_FILES
|
||||
application/argumentparser.cpp
|
||||
application/commandlineutils.cpp
|
||||
application/failure.cpp
|
||||
application/fakeqtconfigarguments.cpp
|
||||
chrono/datetime.cpp
|
||||
chrono/period.cpp
|
||||
chrono/timespan.cpp
|
||||
conversion/binaryconversion.cpp
|
||||
conversion/conversionexception.cpp
|
||||
conversion/stringconversion.cpp
|
||||
io/ansiescapecodes.cpp
|
||||
io/binaryreader.cpp
|
||||
io/binarywriter.cpp
|
||||
io/bitreader.cpp
|
||||
io/inifile.cpp
|
||||
io/path.cpp
|
||||
math/math.cpp
|
||||
misc/random.cpp
|
||||
)
|
||||
|
||||
# meta data
|
||||
set(META_PROJECT_NAME c++utilities)
|
||||
set(META_APP_NAME "C++ Utilities")
|
||||
set(META_APP_AUTHOR "Martchus")
|
||||
set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}")
|
||||
set(META APP_DESCRIPTION "Common C++ classes and routines used by my applications such as argument parser, IO and conversion utilities.")
|
||||
set(META_APP_DESCRIPTION "Common C++ classes and routines used by my applications such as argument parser, IO and conversion utilities.")
|
||||
set(META_VERSION_MAJOR 3)
|
||||
set(META_VERSION_MINOR 0)
|
||||
set(META_VERSION_PATCH 0)
|
||||
|
||||
# define project
|
||||
project(${META_PROJECT_NAME})
|
||||
set(META_APP_VERSION ${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH})
|
||||
|
||||
# stringification of meta data
|
||||
set(META_PROJECT_NAME_STR "\"${META_PROJECT_NAME}\"")
|
||||
set(META_APP_NAME_STR "\"${META_APP_NAME}\"")
|
||||
set(META_APP_AUTHOR_STR "\"${META_APP_AUTHOR}\"")
|
||||
set(META_APP_URL_STR "\"${META_APP_URL}\"")
|
||||
set(APP_DESCRIPTION_STR "\"${APP_DESCRIPTION}\"")
|
||||
set(META_APP_VERSION_STR "\"${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH}\"")
|
||||
set(META_APP_DESCRIPTION_STR "\"${META_APP_DESCRIPTION}\"")
|
||||
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
|
||||
configure_file (
|
||||
"${PROJECT_SOURCE_DIR}/config.h.in"
|
||||
"${PROJECT_BINARY_DIR}/config.h"
|
||||
configure_file(
|
||||
"${PROJECT_SOURCE_DIR}/resources/config.h.in"
|
||||
"${PROJECT_BINARY_DIR}/resources/config.h"
|
||||
)
|
||||
include_directories("${PROJECT_BINARY_DIR}")
|
||||
|
||||
# add source and header files
|
||||
file(GLOB_RECURSE SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cpp" "*.c")
|
||||
file(GLOB_RECURSE HEADER_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.h")
|
||||
# add windows resource file
|
||||
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 "dll")
|
||||
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)
|
||||
|
||||
# remove library prefix when building with mingw-w64 (just for consistancy with qmake)
|
||||
if(MINGW)
|
||||
set(CMAKE_SHARED_LIBRARY_PREFIX "")
|
||||
endif(MINGW)
|
||||
|
||||
# executable and linking
|
||||
add_library(${META_PROJECT_NAME} SHARED ${HEADER_FILES} ${SRC_FILES})
|
||||
target_link_libraries(${META_PROJECT_NAME})
|
||||
set_target_properties(${META_PROJECT_NAME} PROPERTIES VERSION ${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH} SOVERSION ${META_VERSION_MAJOR})
|
||||
|
||||
# enable C++11
|
||||
set_property(TARGET ${META_PROJECT_NAME} PROPERTY CXX_STANDARD 11)
|
||||
add_library(${META_PROJECT_NAME} SHARED ${HEADER_FILES} ${SRC_FILES} ${RES_FILES} ${WINDOWS_ICON_PATH})
|
||||
set_target_properties(${META_PROJECT_NAME} PROPERTIES
|
||||
VERSION ${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH}
|
||||
SOVERSION ${META_VERSION_MAJOR}
|
||||
CXX_STANDARD 11
|
||||
)
|
||||
|
||||
# add install target
|
||||
install(TARGETS ${META_PROJECT_NAME}
|
||||
RUNTIME DESTINATION bin
|
||||
COMPONENT binary
|
||||
LIBRARY DESTINATION lib
|
||||
COMPONENT binary
|
||||
ARCHIVE DESTINATION lib
|
||||
COMPONENT binary
|
||||
)
|
||||
foreach(HEADER_FILE ${HEADER_FILES})
|
||||
get_filename_component(HEADER_DIR ${HEADER_FILE} DIRECTORY)
|
||||
install(FILES ${HEADER_FILE} DESTINATION include/${META_PROJECT_NAME}/${HEADER_DIR})
|
||||
install(
|
||||
FILES ${HEADER_FILE}
|
||||
DESTINATION include/${META_PROJECT_NAME}/${HEADER_DIR}
|
||||
COMPONENT header
|
||||
)
|
||||
endforeach()
|
||||
|
||||
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-header
|
||||
DEPENDS ${META_PROJECT_NAME}
|
||||
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=header -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
|
||||
)
|
||||
add_custom_target(install-mingw-w64
|
||||
DEPENDS install-binary install-header
|
||||
)
|
||||
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 install-header
|
||||
)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# meta data
|
||||
projectname = c++utilities
|
||||
appname = "C++ Utilities"
|
||||
appauthor = Martchus
|
||||
|
@ -11,58 +12,64 @@ VERSION = 3.0.0
|
|||
}
|
||||
}
|
||||
|
||||
# basic configuration: shared library, no Qt
|
||||
TEMPLATE = lib
|
||||
CONFIG -= qt
|
||||
CONFIG += shared
|
||||
|
||||
SOURCES += \
|
||||
application/argumentparser.cpp \
|
||||
application/failure.cpp \
|
||||
io/binarywriter.cpp \
|
||||
io/binaryreader.cpp \
|
||||
io/path.cpp \
|
||||
conversion/stringconversion.cpp \
|
||||
conversion/conversionexception.cpp \
|
||||
chrono/timespan.cpp \
|
||||
chrono/datetime.cpp \
|
||||
chrono/period.cpp \
|
||||
math/math.cpp \
|
||||
application/fakeqtconfigarguments.cpp \
|
||||
io/ansiescapecodes.cpp \
|
||||
misc/random.cpp \
|
||||
io/bitreader.cpp \
|
||||
application/commandlineutils.cpp \
|
||||
io/inifile.cpp
|
||||
|
||||
# add project files
|
||||
HEADERS += \
|
||||
application/global.h \
|
||||
application/argumentparser.h \
|
||||
application/commandlineutils.h \
|
||||
application/failure.h \
|
||||
io/binarywriter.h \
|
||||
io/binaryreader.h \
|
||||
io/path.h \
|
||||
conversion/types.h \
|
||||
conversion/widen.h \
|
||||
conversion/binaryconversion.h \
|
||||
conversion/stringconversion.h \
|
||||
conversion/conversionexception.h \
|
||||
chrono/timespan.h \
|
||||
application/fakeqtconfigarguments.h \
|
||||
application/global.h \
|
||||
chrono/datetime.h \
|
||||
chrono/period.h \
|
||||
math/math.h \
|
||||
io/copy.h \
|
||||
chrono/timespan.h \
|
||||
conversion/binaryconversion.h \
|
||||
conversion/binaryconversionprivate.h \
|
||||
application/fakeqtconfigarguments.h \
|
||||
conversion/conversionexception.h \
|
||||
conversion/stringconversion.h \
|
||||
conversion/types.h \
|
||||
conversion/widen.h \
|
||||
io/ansiescapecodes.h \
|
||||
misc/memory.h \
|
||||
misc/random.h \
|
||||
io/binaryreader.h \
|
||||
io/binarywriter.h \
|
||||
io/bitreader.h \
|
||||
application/commandlineutils.h \
|
||||
io/inifile.h
|
||||
io/copy.h \
|
||||
io/inifile.h \
|
||||
io/path.h \
|
||||
math/math.h \
|
||||
misc/memory.h \
|
||||
misc/random.h
|
||||
|
||||
SOURCES += \
|
||||
application/argumentparser.cpp \
|
||||
application/commandlineutils.cpp \
|
||||
application/failure.cpp \
|
||||
application/fakeqtconfigarguments.cpp \
|
||||
chrono/datetime.cpp \
|
||||
chrono/period.cpp \
|
||||
chrono/timespan.cpp \
|
||||
conversion/binaryconversion.cpp \
|
||||
conversion/conversionexception.cpp \
|
||||
conversion/stringconversion.cpp \
|
||||
io/ansiescapecodes.cpp \
|
||||
io/binaryreader.cpp \
|
||||
io/binarywriter.cpp \
|
||||
io/bitreader.cpp \
|
||||
io/inifile.cpp \
|
||||
io/path.cpp \
|
||||
math/math.cpp \
|
||||
misc/random.cpp
|
||||
|
||||
OTHER_FILES += \
|
||||
README.md \
|
||||
LICENSE
|
||||
LICENSE \
|
||||
CMakeLists.txt \
|
||||
resources/config.h.in \
|
||||
resources/windows.rc.in
|
||||
|
||||
# installs
|
||||
mingw-w64-install {
|
||||
|
|
56
general.pri
56
general.pri
|
@ -1,28 +1,12 @@
|
|||
#dirs
|
||||
# specify build directories for moc, object and rcc files
|
||||
MOC_DIR = ./moc
|
||||
OBJECTS_DIR = ./obj
|
||||
RCC_DIR = ./res
|
||||
# compiler flags
|
||||
|
||||
# compiler flags: enable C++11
|
||||
QMAKE_CXXFLAGS += -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
|
||||
win32-g++:QMAKE_TARGET.arch = $$QMAKE_HOST.arch
|
||||
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++-32:QMAKE_TARGET.arch = x86
|
||||
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 {
|
||||
DEFINES += CONFIG_MOBILE
|
||||
} else:desktop {
|
||||
|
@ -61,7 +68,7 @@ no-gui {
|
|||
}
|
||||
guiqtquick {
|
||||
message("Configured for Qt Quick GUI support.")
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += quick
|
||||
QT += quick
|
||||
CONFIG(debug, debug|release) {
|
||||
CONFIG += qml_debug
|
||||
}
|
||||
|
@ -69,11 +76,12 @@ guiqtquick {
|
|||
}
|
||||
guiqtwidgets {
|
||||
message("Configured for Qt widgets GUI support.")
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
QT += widgets
|
||||
DEFINES += GUI_QTWIDGETS
|
||||
DEFINES += MODEL_UNDO_SUPPORT
|
||||
}
|
||||
# Windows stuff: configuration for cross compliation with mingw-w64
|
||||
|
||||
# configuration for cross compliation with mingw-w64
|
||||
win32 {
|
||||
QMAKE_TARGET_PRODUCT = "$${appname}"
|
||||
QMAKE_TARGET_COPYRIGHT = "by $${appauthor}"
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
# if defined(UNDER_CE)
|
||||
# include <winbase.h>
|
||||
# else
|
||||
# include <windows.h>
|
||||
# endif
|
||||
|
||||
@WINDOWS_ICON_RC_ENTRY@
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION @META_VERSION_MAJOR@,@META_VERSION_MINOR@,@META_VERSION_PATCH@,0
|
||||
PRODUCTVERSION @META_VERSION_MAJOR@,@META_VERSION_MINOR@,@META_VERSION_PATCH@,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS VS_FF_DEBUG
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS VOS__WINDOWS32
|
||||
FILETYPE VFT_DLL
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "@META_APP_AUTHOR@\0"
|
||||
VALUE "FileDescription", "@META_APP_DESCRIPTION@.\0"
|
||||
VALUE "FileVersion", "@META_APP_VERSION@\0"
|
||||
VALUE "LegalCopyright", "by @META_APP_AUTHOR@\0"
|
||||
VALUE "OriginalFilename", "@META_PROJECT_NAME@.@WINDOWS_EXT@\0"
|
||||
VALUE "ProductName", "@META_APP_NAME@\0"
|
||||
VALUE "ProductVersion", "@META_APP_VERSION@\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x0409, 1200
|
||||
END
|
||||
END
|
||||
/* End of Version info */
|
Loading…
Reference in New Issue