improved project files
This commit is contained in:
parent
372154ce2a
commit
67faf53825
143
CMakeLists.txt
143
CMakeLists.txt
|
@ -1,39 +1,115 @@
|
|||
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
|
||||
|
||||
# add project files
|
||||
set(HEADER_FILES
|
||||
aboutdialog/aboutdialog.h
|
||||
enterpassworddialog/enterpassworddialog.h
|
||||
misc/dialogutils.h
|
||||
models/checklistmodel.h
|
||||
resources/qtconfigarguments.h
|
||||
resources/resources.h
|
||||
settingsdialog/optioncategory.h
|
||||
settingsdialog/optioncategoryfiltermodel.h
|
||||
settingsdialog/optioncategorymodel.h
|
||||
settingsdialog/optionpage.h
|
||||
settingsdialog/settingsdialog.h
|
||||
widgets/buttonoverlay.h
|
||||
widgets/clearcombobox.h
|
||||
widgets/clearlineedit.h
|
||||
widgets/clearplaintextedit.h
|
||||
widgets/clearspinbox.h
|
||||
widgets/iconbutton.h
|
||||
)
|
||||
set(SRC_FILES
|
||||
aboutdialog/aboutdialog.cpp
|
||||
enterpassworddialog/enterpassworddialog.cpp
|
||||
misc/dialogutils.cpp
|
||||
models/checklistmodel.cpp
|
||||
resources/qtconfigarguments.cpp
|
||||
resources/resources.cpp
|
||||
settingsdialog/optioncategory.cpp
|
||||
settingsdialog/optioncategoryfiltermodel.cpp
|
||||
settingsdialog/optioncategorymodel.cpp
|
||||
settingsdialog/optionpage.cpp
|
||||
settingsdialog/settingsdialog.cpp
|
||||
widgets/buttonoverlay.cpp
|
||||
widgets/clearcombobox.cpp
|
||||
widgets/clearlineedit.cpp
|
||||
widgets/clearplaintextedit.cpp
|
||||
widgets/clearspinbox.cpp
|
||||
widgets/iconbutton.cpp
|
||||
resources/qtutilsicons.qrc
|
||||
)
|
||||
|
||||
# meta data
|
||||
set(META_PROJECT_NAME qtutilities)
|
||||
set(META_APP_NAME "Qt Utilities")
|
||||
set(META_APP_AUTHOR "Martchus")
|
||||
set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}")
|
||||
set(META APP_DESCRIPTION "Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models.")
|
||||
set(META_APP_DESCRIPTION "Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models.")
|
||||
set(META_VERSION_MAJOR 3)
|
||||
set(META_VERSION_MINOR 0)
|
||||
set(META_VERSION_PATCH 1)
|
||||
|
||||
# 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" "*.qrc")
|
||||
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)
|
||||
|
||||
# enable capslock detection
|
||||
add_definitions(-DPLATFORM_SPECIFIC_CAPSLOCK_DETECTION)
|
||||
# remove library prefix when building with mingw-w64 (just for consistancy with qmake)
|
||||
if(MINGW)
|
||||
set(CMAKE_SHARED_LIBRARY_PREFIX "")
|
||||
endif(MINGW)
|
||||
|
||||
# enable Qt Widgets GUI, enable capslock detection
|
||||
add_definitions(
|
||||
-DGUI_QTWIDGETS
|
||||
-DMODEL_UNDO_SUPPORT
|
||||
-DPLATFORM_SPECIFIC_CAPSLOCK_DETECTION
|
||||
)
|
||||
|
||||
# check required Qt 5 modules
|
||||
find_package(Qt5Core REQUIRED)
|
||||
|
@ -47,24 +123,49 @@ set(CMAKE_AUTORCC ON)
|
|||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
# executable and linking
|
||||
add_library(${META_PROJECT_NAME} SHARED ${HEADER_FILES} ${SRC_FILES})
|
||||
set(EXTRA_LIBS "")
|
||||
add_library(${META_PROJECT_NAME} SHARED ${HEADER_FILES} ${SRC_FILES} ${RES_FILES} ${WINDOWS_ICON_PATH})
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES Linux)
|
||||
set(EXTRA_LIBS X11)
|
||||
endif()
|
||||
target_link_libraries(${META_PROJECT_NAME} c++utilities Qt5::Core Qt5::Widgets ${EXTRA_LIBS})
|
||||
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)
|
||||
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
|
||||
)
|
||||
|
|
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}"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# meta data
|
||||
projectname = qtutilities
|
||||
appname = "Qt Utilities"
|
||||
appauthor = Martchus
|
||||
|
@ -11,22 +12,44 @@ VERSION = 3.0.1
|
|||
}
|
||||
}
|
||||
|
||||
# basic configuration: shared library
|
||||
TEMPLATE = lib
|
||||
QT += core gui
|
||||
CONFIG += shared
|
||||
|
||||
# enable platform specific capslock detection (for password dialog)
|
||||
CONFIG(noplatformspecificcapslockdetection, noplatformspecificcapslockdetection|platformspecificcapslockdetection) {
|
||||
DEFINES -= PLATFORM_SPECIFIC_CAPSLOCK_DETECTION
|
||||
} else {
|
||||
DEFINES += PLATFORM_SPECIFIC_CAPSLOCK_DETECTION
|
||||
}
|
||||
|
||||
# add project files
|
||||
HEADERS += resources/resources.h \
|
||||
models/checklistmodel.h \
|
||||
resources/qtconfigarguments.h \
|
||||
misc/dialogutils.h
|
||||
|
||||
SOURCES += resources/resources.cpp \
|
||||
models/checklistmodel.cpp \
|
||||
resources/qtconfigarguments.cpp \
|
||||
misc/dialogutils.cpp
|
||||
|
||||
contains(DEFINES, GUI_QTWIDGETS) {
|
||||
HEADERS += aboutdialog/aboutdialog.h \
|
||||
enterpassworddialog/enterpassworddialog.h \
|
||||
settingsdialog/optioncategorymodel.h \
|
||||
settingsdialog/settingsdialog.h \
|
||||
settingsdialog/optioncategory.h \
|
||||
settingsdialog/optionpage.h \
|
||||
settingsdialog/optioncategoryfiltermodel.h \
|
||||
widgets/clearlineedit.h \
|
||||
widgets/iconbutton.h \
|
||||
widgets/buttonoverlay.h \
|
||||
widgets/clearcombobox.h \
|
||||
widgets/clearspinbox.h \
|
||||
widgets/clearplaintextedit.h
|
||||
|
||||
SOURCES += aboutdialog/aboutdialog.cpp \
|
||||
enterpassworddialog/enterpassworddialog.cpp \
|
||||
settingsdialog/optioncategorymodel.cpp \
|
||||
|
@ -46,32 +69,17 @@ contains(DEFINES, GUI_QTWIDGETS) {
|
|||
settingsdialog/settingsdialog.ui
|
||||
}
|
||||
|
||||
HEADERS += resources/resources.h \
|
||||
models/checklistmodel.h \
|
||||
resources/qtconfigarguments.h \
|
||||
misc/dialogutils.h
|
||||
|
||||
contains(DEFINES, GUI_QTWIDGETS) {
|
||||
HEADERS += aboutdialog/aboutdialog.h \
|
||||
enterpassworddialog/enterpassworddialog.h \
|
||||
settingsdialog/optioncategorymodel.h \
|
||||
settingsdialog/settingsdialog.h \
|
||||
settingsdialog/optioncategory.h \
|
||||
settingsdialog/optionpage.h \
|
||||
settingsdialog/optioncategoryfiltermodel.h \
|
||||
widgets/clearlineedit.h \
|
||||
widgets/iconbutton.h \
|
||||
widgets/buttonoverlay.h \
|
||||
widgets/clearcombobox.h \
|
||||
widgets/clearspinbox.h \
|
||||
widgets/clearplaintextedit.h
|
||||
}
|
||||
RESOURCES += resources/qtutilsicons.qrc
|
||||
|
||||
OTHER_FILES += \
|
||||
README.md \
|
||||
LICENSE
|
||||
LICENSE \
|
||||
CMakeLists.txt \
|
||||
resources/config.h.in \
|
||||
resources/windows.rc.in
|
||||
|
||||
# libs
|
||||
|
||||
# add libs
|
||||
CONFIG(debug, debug|release) {
|
||||
LIBS += -lc++utilitiesd
|
||||
} else {
|
||||
|
@ -83,8 +91,6 @@ contains(DEFINES, PLATFORM_SPECIFIC_CAPSLOCK_DETECTION) {
|
|||
}
|
||||
}
|
||||
|
||||
RESOURCES += resources/qtutilsicons.qrc
|
||||
|
||||
# installs
|
||||
mingw-w64-install {
|
||||
target.path = $$(INSTALL_ROOT)
|
||||
|
@ -103,4 +109,3 @@ for(dir, $$list(aboutdialog enterpassworddialog models resources settingsdialog
|
|||
inc_$${dir}.files = $${dir}/*.h
|
||||
INSTALLS += inc_$${dir}
|
||||
}
|
||||
|
||||
|
|
|
@ -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