qmake added Windows RC and manifest files

Windows RC and manifest files are compiled and embedded only on Windows
and when a shared library is built.
Also removed TinyOrm_mingw.rc file, RC file for MinGW is injected
through the main TinyOrm.rc.in file, I had to do it this way because is
not possible to pass more RC files by qmake's RC_FILE variable, cmake
can do this without problems.

 - bugfix FILEFLAGS, FILEFLAGSMASK for debug configuration was not set
This commit is contained in:
silverqx
2021-10-02 12:52:06 +02:00
parent d9d6992439
commit e0f61b97fc
11 changed files with 140 additions and 43 deletions
+5
View File
@@ -100,6 +100,11 @@ namespace Relations {
// BUG qmake impossible to add d postfix for dlls silverqx
// BUG SemVer version cmake/qmake silverqx
// CUR cmake/qmake SOVERSION silverqx
// CUR qmake unify all CONFIG(debug/relase, ...), modify tiny_configure_cmake_rc() writefile by build_pass config type silverqx
// CUR tst_version on mingw throws error silverqx
// CUR decide if tst_version checkFileVersion_*() tests will be enabled on mignw silverqx
// CUR 0.1.0 vs 0.1.0.0 Product/FileVersion, investigate, also check versions in pc, prl, ... silverqx
// CUR conf.pri in pro file bottom, so user can override everything silverqx
/*! Base model class. */
template<typename Derived, AllRelationsConcept ...AllRelations>
class Model :
+1 -1
View File
@@ -3,4 +3,4 @@
PRECOMPILED_HEADER = $$quote($$PWD/pch.h)
DEFINES += USING_PCH
DEFINES *= USING_PCH
@@ -0,0 +1,76 @@
# Include Windows resource and manifest files.
defineTest(tiny_resource_and_manifest) {
# Relevant for shared library only
!CONFIG(shared, dll|shared|static|staticlib): \
CONFIG(dll, dll|shared|static|staticlib): \
return()
# Path to the resources folder, relative to the currently processed project
isEmpty(1): resourcesFolder = resources
else: resourcesFolder = $$1
# Windows Resource file
rcFile = $$tiny_configure_cmake_rc($$resourcesFolder)
# Needed in the RC file, MinGW does not define _DEBUG macro
mingw:CONFIG(debug, debug|release): DEFINES += _DEBUG
RC_FILE = $$rcFile
# Manifest file
CONFIG -= embed_manifest_dll
# Resource folder for the currently processed project
resourcePath = $$tiny_get_resource_folder($$resourcesFolder)
# On MSVC use EMBED and on MinGW injected through the RC file
!mingw: \
QMAKE_LFLAGS += \
/MANIFEST:EMBED \
/MANIFESTINPUT:$$shell_quote($$resourcePath/$${TARGET}.dll.manifest)
export(DEFINES)
export(RC_FILE)
export(CONFIG)
export(QMAKE_LFLAGS)
}
# Substitute cmake variables in the Windows RC file, is better to reuse existing Windows
# RC file than manage two practically the same files.
defineReplace(tiny_configure_cmake_rc) {
rcFile = $$absolute_path($$PWD/$$1/$${TARGET}.rc.in)
exists(rcFile) {
error( "Windows RC file $$1 passed to the tiny_configure_cmake_rc() does not\
exists." )
}
rcFileContent = $$cat($$rcFile, blob)
# Support OriginalFilename in the Windows RC file
load(resolve_target)
rcFileContent ~= s/@$${TARGET}_target@/$$TARGET
rcFileContent ~= s/\\$<TARGET_FILE_NAME:$$TARGET>/$$basename(QMAKE_RESOLVED_TARGET)
# Obtain a full filepath of the Windows RC file
rcFilename = $$str_member($$rcFile, 0, -4)
rcFilename = $$basename(rcFilename)
rcFilepath = $$quote($$OUT_PWD/tmp/$$rcFilename)
!write_file($$rcFilepath, rcFileContent) {
error( "Can not write to the file $${rcFilepath}." )
}
return($$rcFilepath)
}
# Find resource folder for the currently processed project, needed because src.pro has
# unusual location, is in the subfolder.
defineReplace(tiny_get_resource_folder) {
folder = $$absolute_path($$1, $$_PRO_FILE_PWD_)
exists($$folder): return($$folder)
error( "Can not find the 'resources' folder for $$basename(_PRO_FILE_) project,\
expected folder location is $$_PRO_FILE_PWD_/resources." )
}
+5 -1
View File
@@ -13,7 +13,7 @@ IDI_ICON1 ICON "icons/@TinyOrm_target@.ico"
#define VER_ORIGINALFILENAME_STR "$<TARGET_FILE_NAME:@TinyOrm_target@>\0"
#if $<CONFIG:Debug>
#ifdef _DEBUG
# define VER_DEBUG VS_FF_DEBUG
#else
# define VER_DEBUG 0
@@ -49,3 +49,7 @@ VS_VERSION_INFO VERSIONINFO
END
END
/* End of Version info */
#ifdef __MINGW32__
ISOLATIONAWARE_MANIFEST_RESOURCE_ID RT_MANIFEST "TinyOrm.dll.manifest"
#endif
-5
View File
@@ -1,5 +0,0 @@
#pragma code_page(65001) // UTF-8
#include <windows.h>
1 RT_MANIFEST "TinyOrm.dll.manifest"
+13 -10
View File
@@ -34,25 +34,28 @@ build_tests {
# TinyORM library header and source files
# ---
# tiny_version_numbers() depends on HEADERS (version.hpp)
include(../include/include.pri)
include(src.pri)
# File version and Windows manifest
# File version
# ---
# Find version numbers in a version header file and assign them to the
# Find version numbers in the version header file and assign them to the
# <TARGET>_VERSION_<MAJOR,MINOR,PATCH,TWEAK> and also to the VERSION variable.
load(tiny_version_numbers)
tiny_version_numbers()
win32-msvc {
QMAKE_TARGET_PRODUCT = TinyORM
QMAKE_TARGET_DESCRIPTION = TinyORM user-friendly ORM
QMAKE_TARGET_COMPANY = Crystal Studio
QMAKE_TARGET_COPYRIGHT = Copyright (©) 2021 Crystal Studio
# RC_ICONS = images/$${TARGET}.ico
RC_LANG = 1033
}
# Windows resource and manifest files
# ---
# Find icons, Windows manifest on MinGW and orm/version.hpp
RC_INCLUDEPATH = \
$$quote($$TINYORM_SOURCE_TREE/include/) \
$$quote($$TINYORM_SOURCE_TREE/resources/)
load(tiny_resource_and_manifest)
tiny_resource_and_manifest(../resources)
# User Configuration
# ---
@@ -1,7 +1,9 @@
#include <QCoreApplication>
#include <QtTest>
#if defined(_MSC_VER) && defined(TINYTEST_VERSION_IS_SHARED_BUILD)
#include <qt_windows.h>
#endif
#include "fs.hpp"
+3 -3
View File
@@ -1,9 +1,7 @@
include($$TINYORM_SOURCE_TREE/tests/qmake/common.pri)
include($$TINYORM_SOURCE_TREE/tests/qmake/utils.pri)
HEADERS += \
$$PWD/include/versiondebug_qmake.hpp.in \
$$OUT_PWD/include/versiondebug_qmake.hpp \
HEADERS += $$PWD/include/versiondebug_qmake.hpp.in
SOURCES = tst_version.cpp
@@ -28,6 +26,8 @@ win32-msvc {
QMAKE_SUBSTITUTES += $$quote(include/versiondebug_qmake.hpp.in)
HEADERS += $$OUT_PWD/include/versiondebug_qmake.hpp
INCLUDEPATH += $$quote($$OUT_PWD/include/)
LIBS += -lVersion
+5 -1
View File
@@ -13,7 +13,7 @@
#define VER_ORIGINALFILENAME_STR "$<TARGET_FILE_NAME:@TinyUtils_target@>\0"
#if $<CONFIG:Debug>
#ifdef _DEBUG
# define VER_DEBUG VS_FF_DEBUG
#else
# define VER_DEBUG 0
@@ -49,3 +49,7 @@ VS_VERSION_INFO VERSIONINFO
END
END
/* End of Version info */
#ifdef __MINGW32__
ISOLATIONAWARE_MANIFEST_RESOURCE_ID RT_MANIFEST "TinyUtils.dll.manifest"
#endif
+6
View File
@@ -0,0 +1,6 @@
# Use Precompiled headers (PCH)
# ---
PRECOMPILED_HEADER = $$quote($$PWD/pch.h)
DEFINES *= USING_PCH
+24 -22
View File
@@ -3,29 +3,33 @@ QT -= gui
TEMPLATE = lib
TARGET = TinyUtils
# TinyUtils library specific configuration
# ---
CONFIG *= qt link_prl create_prl create_pc create_libtool
# Common configuration
# ---
include(../../qmake/common.pri)
# TinyUtils library specific configuration
# ---
CONFIG *= qt link_prl create_prl create_pc create_libtool
# TinyUtils library defines
# ---
DEFINES += PROJECT_TINYUTILS
# Build as shared library
DEFINES += UTILS_BUILDING_SHARED
# Build as the shared library
CONFIG(shared, dll|shared|static|staticlib) | CONFIG(dll, dll|shared|static|staticlib) {
DEFINES += UTILS_BUILDING_SHARED
}
# TinyUtils library header and source files
# ---
# tiny_version_numbers() depends on HEADERS (version.hpp)
include(src/src.pri)
# File version and windows manifest
# File version
# ---
# Find version numbers in a version header file and assign them to the
@@ -33,14 +37,16 @@ include(src/src.pri)
load(tiny_version_numbers)
tiny_version_numbers()
win32-msvc {
QMAKE_TARGET_PRODUCT = TinyUtils
QMAKE_TARGET_DESCRIPTION = Utils library for TinyORM tests
QMAKE_TARGET_COMPANY = Crystal Studio
QMAKE_TARGET_COPYRIGHT = Copyright (©) 2020 Crystal Studio
# RC_ICONS = images/$${$$TARGET}.ico
RC_LANG = 1033
}
# Windows resource and manifest files
# ---
# Find orm/version.hpp
RC_INCLUDEPATH = $$quote($$TINYORM_SOURCE_TREE/tests/utils/src/)
# Find Windows manifest
mingw: RC_INCLUDEPATH += $$quote($$TINYORM_SOURCE_TREE/tests/utils/resources/)
load(tiny_resource_and_manifest)
tiny_resource_and_manifest()
# User Configuration
# ---
@@ -56,14 +62,10 @@ else {
# Use Precompiled headers (PCH)
# ---
PRECOMPILED_HEADER = $$quote($$PWD/src/pch.h)
precompile_header:!isEmpty(PRECOMPILED_HEADER) {
DEFINES += USING_PCH
precompile_header {
include($$PWD/src/pch.pri)
}
HEADERS += $$quote($$PWD/src/pch.h)
# TinyORM library headers include path
# ---