qcdx 0.2.0__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {qcdx-0.2.0 → qcdx-0.3.0}/.github/actions/pk-setup/action.yml +89 -9
- {qcdx-0.2.0 → qcdx-0.3.0}/.gitignore +3 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/PKG-INFO +5 -2
- {qcdx-0.2.0 → qcdx-0.3.0}/README.md +3 -0
- qcdx-0.3.0/cmake/projectkit/AppPaths.cmake +165 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/ApplicationCreator.cmake +62 -2
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/ProjectKit.cmake +1 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/ProjectOptions.cmake +40 -29
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/ProjectSetup.cmake +17 -5
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/StaticAnalysis.cmake +28 -7
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/ToolCreator.cmake +4 -10
- qcdx-0.3.0/cmake/projectkit/VERSION +1 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/docs/ANALYSER_LAUNCHER.md +12 -7
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/docs/VERIFY.md +4 -1
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/scripts/helpers/pk/deps.py +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/scripts/pklib/verify.py +12 -6
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/scripts/pklib/verify_base.py +25 -5
- qcdx-0.3.0/cmake/projectkit/templates/app_paths/app_paths.c.in +655 -0
- qcdx-0.3.0/cmake/projectkit/templates/app_paths/app_paths.cpp.in +165 -0
- qcdx-0.3.0/cmake/projectkit/templates/app_paths/app_paths.h.in +49 -0
- qcdx-0.3.0/cmake/projectkit/templates/app_paths/app_paths.hpp.in +41 -0
- qcdx-0.3.0/docs/DISTRIBUTION.md +3 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/docs/FROM_ZERO_TO_PROJECT.md +31 -5
- qcdx-0.3.0/docs/GENERATED_FILES.md +429 -0
- qcdx-0.3.0/docs/PLATFORMS.md +168 -0
- qcdx-0.3.0/docs/QCDX_CMAKE_VARIABLES.md +812 -0
- qcdx-0.3.0/docs/RELEASING.md +3 -0
- qcdx-0.3.0/docs/REQUIREMENTS.md +234 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/pyproject.toml +1 -1
- qcdx-0.3.0/src/qcdx/_commit.py +1 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/.clangd +1 -1
- {qcdx-0.2.0 → qcdx-0.3.0}/template/.github/workflows/verify.yml +42 -1
- qcdx-0.3.0/tests/test_changelog.py +51 -0
- qcdx-0.3.0/tests/test_docs.py +35 -0
- qcdx-0.3.0/tests/test_kit_cmake.py +129 -0
- qcdx-0.2.0/cmake/projectkit/VERSION +0 -1
- qcdx-0.2.0/src/qcdx/_commit.py +0 -1
- {qcdx-0.2.0 → qcdx-0.3.0}/CMakeLists.txt +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/LICENSE +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/QCDXConfig.cmake +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/QCDXConfigVersion.cmake +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/CompilerWarnings.cmake +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/ConanBuildDir.cmake +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/Dependencies.cmake +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/FileCollection.cmake +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/HostTools.cmake +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/Layout.cmake +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/LibraryCreator.cmake +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/Packaging.cmake +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/TestCreator.cmake +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/Tooling.cmake +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/docs/PACKAGE.md +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/docs/PK.md +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/docs/PK_DEP.md +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/docs/RELEASE.md +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/docs/TREE.md +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/scripts/analyser_launcher.py +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/scripts/helpers/pk/presets.cmake +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/scripts/pklib/__init__.py +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/scripts/pklib/bootstrap.py +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/scripts/pklib/common.py +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/scripts/pklib/names.py +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/scripts/pklib/package.py +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/scripts/pklib/pk.py +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/scripts/pklib/release.py +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/scripts/pklib/targets.py +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/scripts/pklib/tree.py +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/scripts/pklib/treecmd.py +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/templates/PackageConfig.cmake.in +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/templates/pkgconfig.pc.in +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/test_package/CMakeLists.txt +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/test_package/conanfile.py +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/test_package/src/example.cpp +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/trees/classic.conf +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/cmake/projectkit/trees/minimal.conf +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/conan/test_package/CMakeLists.txt +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/conan/test_package/conanfile.py +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/conanfile.py +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/docs/BUILDING.md +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/docs/RUNNING_PK.md +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/scripts/bootstrap.py +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/scripts/package.py +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/scripts/pk.py +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/scripts/release.py +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/scripts/verify.py +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/src/qcdx/__init__.py +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/src/qcdx/__main__.py +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/src/qcdx/cli.py +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/src/qcdx/layout.py +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/src/qcdx/new.py +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/src/qcdx/registry.py +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/src/qcdx/resources.py +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/.clang-format +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/.clang-tidy +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/.gitattributes +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/.github/workflows/release.yml +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/.gitignore +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/.pre-commit-config.yaml +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/CMakeLists.txt +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/CMakePresets.json +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/README.md +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/apps/CMakeLists.txt +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/apps/qcdx/main.cpp +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/cmake/qcdxConfig.cmake.in +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/cmake/toolchains/aarch64-linux-gnu.cmake +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/cmake/toolchains/aarch64-mingw-llvm-w64.cmake +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/cmake/toolchains/x86_64-linux-gnu.cmake +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/cmake/toolchains/x86_64-mingw-w64.cmake +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/conan.lock +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/conanfile.py +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/deps.json +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/include/qcdx/core.hpp +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/profiles/aarch64-linux-gnu +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/profiles/aarch64-mingw-llvm-w64 +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/profiles/ci-linux-armv8 +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/profiles/ci-linux-x86_64 +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/profiles/ci-macos-armv8 +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/profiles/ci-macos-x86_64 +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/profiles/ci-windows-clang64 +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/profiles/ci-windows-clangarm64 +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/profiles/ci-windows-ucrt64 +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/profiles/native +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/profiles/x86_64-linux-gnu +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/profiles/x86_64-mingw-w64 +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/scripts/helpers/package/package.conf +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/scripts/helpers/release/release.conf +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/scripts/helpers/verify/consumer.cpp +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/scripts/helpers/verify/verify.conf +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/src/CMakeLists.txt +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/src/qcdx/core.cpp +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/tests/CMakeLists.txt +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/tests/qcdx/tests_core.cpp +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/tools/CMakeLists.txt +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/template/tools/codegen.cpp +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/tests/conftest.py +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/tests/test_cli.py +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/tests/test_layout.py +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/tests/test_list.py +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/tests/test_names.py +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/tests/test_new.py +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/tests/test_new_messages.py +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/tests/test_rename.py +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/tests/test_tree.py +0 -0
- {qcdx-0.2.0 → qcdx-0.3.0}/tests/test_tree_apply.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
name: pk-setup
|
|
2
2
|
description: >-
|
|
3
|
-
Toolchain, Conan
|
|
4
|
-
|
|
3
|
+
Toolchain, Conan, the Conan cache and optionally ccache for a verify/release
|
|
4
|
+
target. Used by workflows to only have to set up a target once.
|
|
5
5
|
|
|
6
6
|
inputs:
|
|
7
7
|
target:
|
|
@@ -11,21 +11,49 @@ inputs:
|
|
|
11
11
|
description: MSYS2 environment (UCRT64, CLANG64, CLANGARM64), Windows only.
|
|
12
12
|
default: ''
|
|
13
13
|
cache:
|
|
14
|
-
description:
|
|
14
|
+
description: >-
|
|
15
|
+
'save' restores the Conan cache and saves it when the job succeeds,
|
|
16
|
+
'restore' doesn't save, 'manual' only restores and leaves saving to
|
|
17
|
+
caller (with the outputs conan-key and conan-hit).
|
|
15
18
|
default: save
|
|
19
|
+
compiler-cache:
|
|
20
|
+
description: >-
|
|
21
|
+
'true' installs ccache (kit uses when found) and restores its cache.
|
|
22
|
+
Saving is up to the caller.
|
|
23
|
+
default: 'false'
|
|
16
24
|
conan-version:
|
|
25
|
+
description: Conan version pip installs.
|
|
17
26
|
default: '2.33.0'
|
|
18
27
|
llvm-mingw-tag:
|
|
28
|
+
description: llvm-mingw release tag (cross-aarch64-mingw-llvm-w64 only).
|
|
19
29
|
default: '20260616'
|
|
20
30
|
llvm-mingw-asset:
|
|
21
|
-
|
|
31
|
+
description: Asset of that release to download (Linux x86_64 UCRT build).
|
|
22
32
|
default: llvm-mingw-20260616-ucrt-ubuntu-22.04-x86_64.tar.xz
|
|
23
33
|
llvm-mingw-sha256:
|
|
34
|
+
description: SHA-256 of that asset, checked before it is unpacked.
|
|
24
35
|
default: 534b92e067b22a6b4441f48ae9240a3341b17825d04d577eab0cf85c44b4deda
|
|
25
36
|
|
|
37
|
+
outputs:
|
|
38
|
+
conan-key:
|
|
39
|
+
description: Conan cache key for this target and its dependency files.
|
|
40
|
+
value: ${{ steps.conan-key.outputs.key }}
|
|
41
|
+
conan-hit:
|
|
42
|
+
description: "'true' when Conan cache was restored from conan-key."
|
|
43
|
+
value: ${{ steps.conan-save.outputs.cache-hit || steps.conan-restore.outputs.cache-hit }}
|
|
44
|
+
|
|
26
45
|
runs:
|
|
27
46
|
using: composite
|
|
28
47
|
steps:
|
|
48
|
+
- name: Free disk space
|
|
49
|
+
if: runner.os == 'Linux'
|
|
50
|
+
shell: bash
|
|
51
|
+
run: |
|
|
52
|
+
df -h /
|
|
53
|
+
sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc /usr/local/.ghcup \
|
|
54
|
+
/opt/hostedtoolcache/CodeQL
|
|
55
|
+
df -h /
|
|
56
|
+
|
|
29
57
|
# -------------------------------------------------------------------------
|
|
30
58
|
# Linux and macOS
|
|
31
59
|
# -------------------------------------------------------------------------
|
|
@@ -50,9 +78,13 @@ runs:
|
|
|
50
78
|
shell: bash
|
|
51
79
|
env:
|
|
52
80
|
TARGET: ${{ inputs.target }}
|
|
81
|
+
CCACHE: ${{ inputs.compiler-cache }}
|
|
53
82
|
run: |
|
|
54
83
|
packages=()
|
|
55
84
|
command -v g++-14 >/dev/null || packages+=(g++-14)
|
|
85
|
+
if [ "$CCACHE" = true ]; then
|
|
86
|
+
command -v ccache >/dev/null || packages+=(ccache)
|
|
87
|
+
fi
|
|
56
88
|
case "$TARGET" in
|
|
57
89
|
cross-x86_64-mingw-w64) packages+=(g++-mingw-w64-x86-64) ;;
|
|
58
90
|
cross-aarch64-linux-gnu) command -v aarch64-linux-gnu-gcc >/dev/null || packages+=(g++-aarch64-linux-gnu) ;;
|
|
@@ -69,6 +101,15 @@ runs:
|
|
|
69
101
|
echo "CC=gcc-14" >> "$GITHUB_ENV"
|
|
70
102
|
echo "CXX=g++-14" >> "$GITHUB_ENV"
|
|
71
103
|
|
|
104
|
+
# No auto update: it can take longer than everything else in this action.
|
|
105
|
+
- name: Install ccache
|
|
106
|
+
if: runner.os == 'macOS' && inputs.compiler-cache == 'true'
|
|
107
|
+
shell: bash
|
|
108
|
+
env:
|
|
109
|
+
HOMEBREW_NO_AUTO_UPDATE: '1'
|
|
110
|
+
HOMEBREW_NO_INSTALL_CLEANUP: '1'
|
|
111
|
+
run: command -v ccache >/dev/null || brew install ccache
|
|
112
|
+
|
|
72
113
|
- name: Install llvm-mingw
|
|
73
114
|
if: inputs.target == 'cross-aarch64-mingw-llvm-w64'
|
|
74
115
|
shell: bash
|
|
@@ -106,6 +147,7 @@ runs:
|
|
|
106
147
|
ninja:p
|
|
107
148
|
python-pip:p
|
|
108
149
|
pkgconf:p
|
|
150
|
+
${{ inputs.compiler-cache == 'true' && 'ccache:p' || '' }}
|
|
109
151
|
|
|
110
152
|
# Visual Studio is installed on the runner used, Conan prefers
|
|
111
153
|
# MSVC on Windows, CC/CXX override it.
|
|
@@ -142,22 +184,60 @@ runs:
|
|
|
142
184
|
fi
|
|
143
185
|
echo "profiles=$profiles" >> "$GITHUB_OUTPUT"
|
|
144
186
|
|
|
187
|
+
- name: Conan cache key
|
|
188
|
+
id: conan-key
|
|
189
|
+
shell: bash
|
|
190
|
+
env:
|
|
191
|
+
TARGET: ${{ inputs.target }}
|
|
192
|
+
HASH: ${{ hashFiles('conanfile.py', 'deps.json', 'conan.lock', format('{0}/**', steps.tree.outputs.profiles)) }}
|
|
193
|
+
run: echo "key=conan-$TARGET-$HASH" >> "$GITHUB_OUTPUT"
|
|
194
|
+
|
|
145
195
|
# The key is shared with verify.yml, and caches saved on main can be read
|
|
146
196
|
# from every branch and tag: release runs will reuse verify's packages,
|
|
147
197
|
# NEVER storing a wasteful second copy.
|
|
198
|
+
#
|
|
199
|
+
# The first restore key also matches '<key>-partial-...', the packages a
|
|
200
|
+
# verify run managed to build before it failed or ran out of time; the next
|
|
201
|
+
# run only builds what's missing.
|
|
148
202
|
- if: inputs.cache == 'save'
|
|
203
|
+
id: conan-save
|
|
149
204
|
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
|
150
205
|
with:
|
|
151
206
|
path: ${{ runner.temp }}/conan2/p
|
|
152
|
-
key:
|
|
153
|
-
restore-keys:
|
|
207
|
+
key: ${{ steps.conan-key.outputs.key }}
|
|
208
|
+
restore-keys: |
|
|
209
|
+
${{ steps.conan-key.outputs.key }}
|
|
210
|
+
conan-${{ inputs.target }}-
|
|
154
211
|
|
|
155
|
-
- if: inputs.cache == 'restore'
|
|
212
|
+
- if: inputs.cache == 'restore' || inputs.cache == 'manual'
|
|
213
|
+
id: conan-restore
|
|
156
214
|
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
|
157
215
|
with:
|
|
158
216
|
path: ${{ runner.temp }}/conan2/p
|
|
159
|
-
key:
|
|
160
|
-
restore-keys:
|
|
217
|
+
key: ${{ steps.conan-key.outputs.key }}
|
|
218
|
+
restore-keys: |
|
|
219
|
+
${{ steps.conan-key.outputs.key }}
|
|
220
|
+
conan-${{ inputs.target }}-
|
|
221
|
+
|
|
222
|
+
# -------------------------------------------------------------------------
|
|
223
|
+
# Compiler cache
|
|
224
|
+
# -------------------------------------------------------------------------
|
|
225
|
+
|
|
226
|
+
- name: Point ccache at the runner temp directory
|
|
227
|
+
if: inputs.compiler-cache == 'true'
|
|
228
|
+
shell: bash
|
|
229
|
+
env:
|
|
230
|
+
DIR_VALUE: ${{ runner.temp }}/ccache
|
|
231
|
+
run: |
|
|
232
|
+
echo "CCACHE_DIR=$DIR_VALUE" >> "$GITHUB_ENV"
|
|
233
|
+
echo "CCACHE_MAXSIZE=500M" >> "$GITHUB_ENV"
|
|
234
|
+
|
|
235
|
+
- if: inputs.compiler-cache == 'true'
|
|
236
|
+
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
|
237
|
+
with:
|
|
238
|
+
path: ${{ runner.temp }}/ccache
|
|
239
|
+
key: ccache-${{ inputs.target }}-${{ github.run_id }}
|
|
240
|
+
restore-keys: ccache-${{ inputs.target }}-
|
|
161
241
|
|
|
162
242
|
- name: Detect the default Conan profile
|
|
163
243
|
if: runner.os != 'Windows'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: qcdx
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Create, build, test, package and release C and C++ projects with CMake and Conan
|
|
5
5
|
Project-URL: Homepage, https://github.com/cooldood155/QCDX
|
|
6
6
|
Project-URL: Documentation, https://github.com/cooldood155/QCDX#readme
|
|
@@ -22,7 +22,7 @@ Classifier: Topic :: Software Development :: Code Generators
|
|
|
22
22
|
Requires-Python: >=3.9
|
|
23
23
|
Provides-Extra: tools
|
|
24
24
|
Requires-Dist: cmake>=3.30; extra == 'tools'
|
|
25
|
-
Requires-Dist: conan<3,>=2.
|
|
25
|
+
Requires-Dist: conan<3,>=2.4; extra == 'tools'
|
|
26
26
|
Requires-Dist: ninja; extra == 'tools'
|
|
27
27
|
Description-Content-Type: text/markdown
|
|
28
28
|
|
|
@@ -294,6 +294,9 @@ my-project/
|
|
|
294
294
|
| [`RELEASE.md`](cmake/projectkit/docs/RELEASE.md) | tagged releases: targets, archives, checks, signing |
|
|
295
295
|
| [`PACKAGE.md`](cmake/projectkit/docs/PACKAGE.md) | Conan packaging, editable mode and uploads |
|
|
296
296
|
| [`ANALYSER_LAUNCHER.md`](cmake/projectkit/docs/ANALYSER_LAUNCHER.md) | clang-tidy and cppcheck integration |
|
|
297
|
+
| [`PLATFORMS.md`](docs/PLATFORMS.md) | Every single the compiled code of a QCDX (`pk new`) project can be built for and run on |
|
|
298
|
+
| [`REQUIREMENTS.md`](docs/REQUIREMENTS.md) | External tools needed to develop a QCDX (`pk new`) project |
|
|
299
|
+
| [`GENERATED_FILES.md`](docs/GENERATED_FILES.md) | `app_paths`, the export header, and generating your own files |
|
|
297
300
|
|
|
298
301
|
## License
|
|
299
302
|
|
|
@@ -266,6 +266,9 @@ my-project/
|
|
|
266
266
|
| [`RELEASE.md`](cmake/projectkit/docs/RELEASE.md) | tagged releases: targets, archives, checks, signing |
|
|
267
267
|
| [`PACKAGE.md`](cmake/projectkit/docs/PACKAGE.md) | Conan packaging, editable mode and uploads |
|
|
268
268
|
| [`ANALYSER_LAUNCHER.md`](cmake/projectkit/docs/ANALYSER_LAUNCHER.md) | clang-tidy and cppcheck integration |
|
|
269
|
+
| [`PLATFORMS.md`](docs/PLATFORMS.md) | Every single the compiled code of a QCDX (`pk new`) project can be built for and run on |
|
|
270
|
+
| [`REQUIREMENTS.md`](docs/REQUIREMENTS.md) | External tools needed to develop a QCDX (`pk new`) project |
|
|
271
|
+
| [`GENERATED_FILES.md`](docs/GENERATED_FILES.md) | `app_paths`, the export header, and generating your own files |
|
|
269
272
|
|
|
270
273
|
## License
|
|
271
274
|
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
include_guard(GLOBAL)
|
|
2
|
+
|
|
3
|
+
# pk_add_app_paths(NAME <app> TARGETS <executable>... [LANGUAGE C|CXX])
|
|
4
|
+
#
|
|
5
|
+
# Generates <build>/generated/<app>/app_paths.{hpp,cpp} (CXX) or
|
|
6
|
+
# app_paths.{h,c} (C) from the templates in templates/app_paths/ and compiles
|
|
7
|
+
# them into each target. C++ code includes <<app>/app_paths.hpp> and calls
|
|
8
|
+
# '<app>::app_paths()'; C code includes <<app>/app_paths.h> and calls
|
|
9
|
+
# '<app>_app_paths()'. LANGUAGE defaults to CXX when C++ is enabled, else C.
|
|
10
|
+
#
|
|
11
|
+
# pk_create_app calls this for every application (opt out with
|
|
12
|
+
# NO_APP_PATHS); call it yourself for executables made with add_executable.
|
|
13
|
+
function(pk_add_app_paths)
|
|
14
|
+
set(one_value_args NAME LANGUAGE)
|
|
15
|
+
set(multi_value_args TARGETS)
|
|
16
|
+
cmake_parse_arguments(ARG "" "${one_value_args}" "${multi_value_args}" ${ARGN})
|
|
17
|
+
|
|
18
|
+
if(NOT ARG_NAME)
|
|
19
|
+
message(FATAL_ERROR "pk_add_app_paths (func): No 'NAME' was provided?")
|
|
20
|
+
endif()
|
|
21
|
+
if(NOT ARG_TARGETS)
|
|
22
|
+
message(FATAL_ERROR
|
|
23
|
+
"pk_add_app_paths (func): No 'TARGETS' were provided for '${ARG_NAME}'?")
|
|
24
|
+
endif()
|
|
25
|
+
if(ARG_UNPARSED_ARGUMENTS)
|
|
26
|
+
message(FATAL_ERROR
|
|
27
|
+
"pk_add_app_paths (func): unrecognized arguments for '${ARG_NAME}': "
|
|
28
|
+
"${ARG_UNPARSED_ARGUMENTS}")
|
|
29
|
+
endif()
|
|
30
|
+
|
|
31
|
+
if(NOT ARG_LANGUAGE)
|
|
32
|
+
if(CMAKE_CXX_COMPILER_LOADED)
|
|
33
|
+
set(ARG_LANGUAGE CXX)
|
|
34
|
+
else()
|
|
35
|
+
set(ARG_LANGUAGE C)
|
|
36
|
+
endif()
|
|
37
|
+
endif()
|
|
38
|
+
if(ARG_LANGUAGE STREQUAL "CXX")
|
|
39
|
+
set(header_ext hpp)
|
|
40
|
+
set(source_ext cpp)
|
|
41
|
+
elseif(ARG_LANGUAGE STREQUAL "C")
|
|
42
|
+
set(header_ext h)
|
|
43
|
+
set(source_ext c)
|
|
44
|
+
else()
|
|
45
|
+
message(FATAL_ERROR
|
|
46
|
+
"pk_add_app_paths (func): 'LANGUAGE' must be C or CXX, not "
|
|
47
|
+
"'${ARG_LANGUAGE}'.")
|
|
48
|
+
endif()
|
|
49
|
+
if(NOT CMAKE_${ARG_LANGUAGE}_COMPILER_LOADED)
|
|
50
|
+
message(FATAL_ERROR
|
|
51
|
+
"pk_add_app_paths (func): the generated code is ${ARG_LANGUAGE}, but "
|
|
52
|
+
"${ARG_LANGUAGE} is not enabled in project(${PROJECT_NAME}).")
|
|
53
|
+
endif()
|
|
54
|
+
|
|
55
|
+
# Templates values ----------------------------------------------------------
|
|
56
|
+
# configure_file replaces @NAME@ with the value of the CMake variable NAME;
|
|
57
|
+
# each value is just a variable set in this function's scope.
|
|
58
|
+
|
|
59
|
+
string(MAKE_C_IDENTIFIER "${ARG_NAME}" PK_APP_NAMESPACE)
|
|
60
|
+
set(PK_APP_NAME "${ARG_NAME}")
|
|
61
|
+
set(PK_APP_VERSION "${PROJECT_VERSION}")
|
|
62
|
+
set(PK_APP_C_PREFIX "${PK_APP_NAMESPACE}")
|
|
63
|
+
string(TOUPPER "${PK_APP_NAMESPACE}" PK_APP_C_MACRO_PREFIX)
|
|
64
|
+
|
|
65
|
+
# CMAKE_INSTALL_PREFIX should NOT reach generated code.
|
|
66
|
+
if(IS_ABSOLUTE "${CMAKE_INSTALL_BINDIR}")
|
|
67
|
+
message(WARNING
|
|
68
|
+
"pk_add_app_paths (func): CMAKE_INSTALL_BINDIR is absolute "
|
|
69
|
+
"('${CMAKE_INSTALL_BINDIR}'), so the root can't be derived from the "
|
|
70
|
+
"executable's location; assuming '..'.")
|
|
71
|
+
set(PK_APP_BIN_TO_ROOT "..")
|
|
72
|
+
|
|
73
|
+
else()
|
|
74
|
+
file(RELATIVE_PATH PK_APP_BIN_TO_ROOT
|
|
75
|
+
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}"
|
|
76
|
+
"${CMAKE_INSTALL_PREFIX}")
|
|
77
|
+
if(PK_APP_BIN_TO_ROOT STREQUAL "")
|
|
78
|
+
set(PK_APP_BIN_TO_ROOT ".")
|
|
79
|
+
endif()
|
|
80
|
+
endif()
|
|
81
|
+
|
|
82
|
+
get_property(multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
|
83
|
+
if(multi_config)
|
|
84
|
+
message(WARNING
|
|
85
|
+
"pk_add_app_paths (func): '${CMAKE_GENERATOR}' builds into "
|
|
86
|
+
"bin/<config>/, one level deeper than the install tree; app_paths().root"
|
|
87
|
+
"for '${ARG_NAME}' is only correct once installed. The kit's presets"
|
|
88
|
+
"use the single-config 'Ninja' generator.")
|
|
89
|
+
|
|
90
|
+
elseif(CMAKE_RUNTIME_OUTPUT_DIRECTORY)
|
|
91
|
+
file(RELATIVE_PATH build_bin_to_root
|
|
92
|
+
"${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" "${PROJECT_BINARY_DIR}")
|
|
93
|
+
if(NOT build_bin_to_root STREQUAL PK_APP_BIN_TO_ROOT)
|
|
94
|
+
message(WARNING
|
|
95
|
+
"pk_add_app_paths (func): '${ARG_NAME}' is built in "
|
|
96
|
+
"'${CMAKE_RUNTIME_OUTPUT_DIRECTORY}' but installed in "
|
|
97
|
+
"'${CMAKE_INSTALL_BINDIR}'; app_paths().root will only be correct once"
|
|
98
|
+
"installed.")
|
|
99
|
+
endif()
|
|
100
|
+
endif()
|
|
101
|
+
|
|
102
|
+
if(IS_ABSOLUTE "${CMAKE_INSTALL_DATADIR}")
|
|
103
|
+
set(PK_APP_DATADIR "share")
|
|
104
|
+
else()
|
|
105
|
+
set(PK_APP_DATADIR "${CMAKE_INSTALL_DATADIR}")
|
|
106
|
+
endif()
|
|
107
|
+
|
|
108
|
+
# Write files ---------------------------------------------------------------
|
|
109
|
+
# configure_file only rewrites an output if its content has changed,
|
|
110
|
+
# reconfiguring doesn't force a rebuild, and it registers the template as a
|
|
111
|
+
# configuration dependency, so editing the .in file re-runs CMake on the next
|
|
112
|
+
# build. @ONLY will only expand '@...@' and not '${...}'. Generated files go
|
|
113
|
+
# to the build tree, not source tree.
|
|
114
|
+
|
|
115
|
+
set(template_dir "${PK_MODULE_DIR}/templates/app_paths")
|
|
116
|
+
set(generated_root "${PROJECT_BINARY_DIR}/generated")
|
|
117
|
+
set(out_dir "${generated_root}/${ARG_NAME}")
|
|
118
|
+
|
|
119
|
+
set(header "${out_dir}/app_paths.${header_ext}")
|
|
120
|
+
set(source "${out_dir}/app_paths.${source_ext}")
|
|
121
|
+
configure_file("${template_dir}/app_paths.${header_ext}.in" "${header}" @ONLY)
|
|
122
|
+
configure_file("${template_dir}/app_paths.${source_ext}.in" "${source}" @ONLY)
|
|
123
|
+
|
|
124
|
+
set_source_files_properties("${header}" "${source}"
|
|
125
|
+
PROPERTIES SKIP_LINTING ON)
|
|
126
|
+
|
|
127
|
+
if(ARG_LANGUAGE STREQUAL "C" AND NOT WIN32)
|
|
128
|
+
find_package(Threads REQUIRED)
|
|
129
|
+
endif()
|
|
130
|
+
|
|
131
|
+
# Files to targets ----------------------------------------------------------
|
|
132
|
+
# The .cpp is compiled into each executable. The header goes in a FILE_SET
|
|
133
|
+
# with the base <build>/generated which puts the folder on the include path,
|
|
134
|
+
# so the code includes it as <app>/app_paths.hpp.
|
|
135
|
+
|
|
136
|
+
foreach(target IN LISTS ARG_TARGETS)
|
|
137
|
+
if(NOT TARGET ${target})
|
|
138
|
+
message(FATAL_ERROR
|
|
139
|
+
"pk_add_app_paths (func): '${target}' is not a target.")
|
|
140
|
+
endif()
|
|
141
|
+
get_target_property(target_type ${target} TYPE)
|
|
142
|
+
if(NOT target_type STREQUAL "EXECUTABLE")
|
|
143
|
+
message(FATAL_ERROR
|
|
144
|
+
"pk_add_app_paths (func): '${target}' is a ${target_type}; app paths "
|
|
145
|
+
"are found from the running executable.")
|
|
146
|
+
endif()
|
|
147
|
+
|
|
148
|
+
target_sources(${target}
|
|
149
|
+
PRIVATE
|
|
150
|
+
"${source}")
|
|
151
|
+
target_sources(${target}
|
|
152
|
+
PRIVATE
|
|
153
|
+
FILE_SET pk_app_paths_${PK_APP_NAMESPACE}_${source_ext}
|
|
154
|
+
TYPE HEADERS
|
|
155
|
+
BASE_DIRS "${generated_root}"
|
|
156
|
+
FILES "${header}")
|
|
157
|
+
|
|
158
|
+
if(WIN32)
|
|
159
|
+
# SHGetKnownFolderPath (shell32) & CoTaskMemFree (ole32).
|
|
160
|
+
target_link_libraries(${target} PRIVATE shell32 ole32)
|
|
161
|
+
elseif(ARG_LANGUAGE STREQUAL "C")
|
|
162
|
+
target_link_libraries(${target} PRIVATE Threads::Threads)
|
|
163
|
+
endif()
|
|
164
|
+
endforeach()
|
|
165
|
+
endfunction()
|
|
@@ -7,13 +7,18 @@ function(pk_create_app)
|
|
|
7
7
|
REQUIRE_PUBLIC_HEADERS
|
|
8
8
|
REQUIRE_PRIVATE_HEADERS
|
|
9
9
|
NO_DEFAULT_LINKS
|
|
10
|
-
NO_INSTALL
|
|
10
|
+
NO_INSTALL
|
|
11
|
+
NO_APP_PATHS
|
|
12
|
+
GUI
|
|
13
|
+
OWN_MANIFEST
|
|
14
|
+
STATIC_RUNTIME)
|
|
11
15
|
|
|
12
16
|
set(one_value_args
|
|
13
17
|
NAME
|
|
14
18
|
LANGUAGE
|
|
15
19
|
SOURCE_DIR
|
|
16
|
-
INCLUDE_DIR
|
|
20
|
+
INCLUDE_DIR
|
|
21
|
+
RC_FILE)
|
|
17
22
|
|
|
18
23
|
set(multi_value_args
|
|
19
24
|
TARGET_NAME
|
|
@@ -78,6 +83,38 @@ function(pk_create_app)
|
|
|
78
83
|
"values: ${ARG_OUTPUT_NAME}")
|
|
79
84
|
endif()
|
|
80
85
|
|
|
86
|
+
if(ARG_RC_FILE)
|
|
87
|
+
cmake_path(ABSOLUTE_PATH ARG_RC_FILE
|
|
88
|
+
BASE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" NORMALIZE)
|
|
89
|
+
if(NOT EXISTS "${ARG_RC_FILE}")
|
|
90
|
+
message(FATAL_ERROR
|
|
91
|
+
"pk_create_app (func): 'RC_FILE' for '${ARG_NAME}' does not exist: "
|
|
92
|
+
"'${ARG_RC_FILE}'.")
|
|
93
|
+
endif()
|
|
94
|
+
get_property(enabled_languages GLOBAL PROPERTY ENABLED_LANGUAGES)
|
|
95
|
+
if(WIN32 AND NOT "RC" IN_LIST enabled_languages)
|
|
96
|
+
message(FATAL_ERROR
|
|
97
|
+
"pk_create_app (func): 'RC_FILE' for '${ARG_NAME}' needs the RC "
|
|
98
|
+
"language; call enable_language(RC) before pk_create_app.")
|
|
99
|
+
endif()
|
|
100
|
+
endif()
|
|
101
|
+
|
|
102
|
+
if(MINGW AND ARG_OWN_MANIFEST)
|
|
103
|
+
if(CMAKE_C_COMPILER)
|
|
104
|
+
set(stub_compiler "${CMAKE_C_COMPILER}")
|
|
105
|
+
else()
|
|
106
|
+
set(stub_compiler "${CMAKE_CXX_COMPILER}")
|
|
107
|
+
endif()
|
|
108
|
+
set(no_manifest_dir "${CMAKE_CURRENT_BINARY_DIR}/${ARG_NAME}_no_default_manifest")
|
|
109
|
+
if(NOT EXISTS "${no_manifest_dir}/default-manifest.o")
|
|
110
|
+
file(WRITE "${no_manifest_dir}/empty.c" "")
|
|
111
|
+
execute_process(
|
|
112
|
+
COMMAND "${stub_compiler}" -c empty.c -o default-manifest.o
|
|
113
|
+
WORKING_DIRECTORY "${no_manifest_dir}"
|
|
114
|
+
COMMAND_ERROR_IS_FATAL ANY)
|
|
115
|
+
endif()
|
|
116
|
+
endif()
|
|
117
|
+
|
|
81
118
|
pk_resolve_files(ARG_SOURCES "'${ARG_NAME}' SOURCES"
|
|
82
119
|
"\\.(c|cc|cpp|cxx)$" ${ARG_SOURCES})
|
|
83
120
|
pk_resolve_files(ARG_PUBLIC_HEADERS "'${ARG_NAME}' PUBLIC_HEADERS"
|
|
@@ -238,8 +275,31 @@ function(pk_create_app)
|
|
|
238
275
|
|
|
239
276
|
target_compile_definitions(${target} PRIVATE
|
|
240
277
|
${prefix}_VERSION_STRING="${PROJECT_VERSION}")
|
|
278
|
+
|
|
279
|
+
if(ARG_GUI)
|
|
280
|
+
set_target_properties(${target} PROPERTIES WIN32_EXECUTABLE TRUE)
|
|
281
|
+
endif()
|
|
282
|
+
if(WIN32 AND ARG_RC_FILE)
|
|
283
|
+
target_sources(${target} PRIVATE "${ARG_RC_FILE}")
|
|
284
|
+
endif()
|
|
285
|
+
if(MINGW AND ARG_OWN_MANIFEST)
|
|
286
|
+
target_link_options(${target} PRIVATE "-B${no_manifest_dir}/")
|
|
287
|
+
endif()
|
|
288
|
+
if(MINGW AND ARG_STATIC_RUNTIME)
|
|
289
|
+
target_link_options(${target} PRIVATE -static)
|
|
290
|
+
endif()
|
|
241
291
|
endforeach()
|
|
242
292
|
|
|
293
|
+
# Generated <name>/app_paths.hpp for apps with C++, or <name>/app_paths.h
|
|
294
|
+
# for C-only apps (AppPaths.cmake).
|
|
295
|
+
if(NOT ARG_NO_APP_PATHS)
|
|
296
|
+
if("CXX" IN_LIST app_languages)
|
|
297
|
+
pk_add_app_paths(NAME ${ARG_NAME} TARGETS ${ARG_TARGET_NAME} LANGUAGE CXX)
|
|
298
|
+
elseif("C" IN_LIST app_languages)
|
|
299
|
+
pk_add_app_paths(NAME ${ARG_NAME} TARGETS ${ARG_TARGET_NAME} LANGUAGE C)
|
|
300
|
+
endif()
|
|
301
|
+
endif()
|
|
302
|
+
|
|
243
303
|
if(ARG_NO_DEFAULT_LINKS)
|
|
244
304
|
set(default_links NO_DEFAULT_LINKS)
|
|
245
305
|
else()
|
|
@@ -16,6 +16,7 @@ include("${CMAKE_CURRENT_LIST_DIR}/Tooling.cmake")
|
|
|
16
16
|
include("${CMAKE_CURRENT_LIST_DIR}/HostTools.cmake")
|
|
17
17
|
include("${CMAKE_CURRENT_LIST_DIR}/FileCollection.cmake")
|
|
18
18
|
include("${CMAKE_CURRENT_LIST_DIR}/LibraryCreator.cmake")
|
|
19
|
+
include("${CMAKE_CURRENT_LIST_DIR}/AppPaths.cmake")
|
|
19
20
|
include("${CMAKE_CURRENT_LIST_DIR}/ApplicationCreator.cmake")
|
|
20
21
|
include("${CMAKE_CURRENT_LIST_DIR}/TestCreator.cmake")
|
|
21
22
|
include("${CMAKE_CURRENT_LIST_DIR}/ToolCreator.cmake")
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
include_guard(GLOBAL)
|
|
2
2
|
|
|
3
|
-
include(
|
|
3
|
+
include(CheckCompilerFlag)
|
|
4
4
|
include(CheckLinkerFlag)
|
|
5
5
|
include(CheckIPOSupported)
|
|
6
6
|
|
|
7
7
|
function(pk_try_compile_option target condition flag)
|
|
8
|
+
pk_main_language(language)
|
|
8
9
|
string(MAKE_C_IDENTIFIER "${PROJECT_NAME}_has_c_${flag}" probe)
|
|
9
|
-
|
|
10
|
+
check_compiler_flag(${language} "${flag}" ${probe})
|
|
10
11
|
|
|
11
12
|
if(${probe})
|
|
12
13
|
target_compile_options(${target} INTERFACE "$<${condition}:${flag}>")
|
|
@@ -14,8 +15,9 @@ function(pk_try_compile_option target condition flag)
|
|
|
14
15
|
endfunction()
|
|
15
16
|
|
|
16
17
|
function(pk_try_link_option target condition flag)
|
|
18
|
+
pk_main_language(language)
|
|
17
19
|
string(MAKE_C_IDENTIFIER "${PROJECT_NAME}_has_l_${flag}" probe)
|
|
18
|
-
check_linker_flag(
|
|
20
|
+
check_linker_flag(${language} "${flag}" ${probe})
|
|
19
21
|
|
|
20
22
|
if(${probe})
|
|
21
23
|
target_link_options(${target} INTERFACE "$<${condition}:${flag}>")
|
|
@@ -25,38 +27,41 @@ endfunction()
|
|
|
25
27
|
macro(pk_add_options_target)
|
|
26
28
|
pk_project_prefix(PK_PREFIX)
|
|
27
29
|
set(_pk_target "${PROJECT_NAME}_options")
|
|
30
|
+
pk_main_language(_pk_main_lang)
|
|
28
31
|
|
|
29
32
|
set(${PK_PREFIX}_SANITIZE "" CACHE STRING
|
|
30
|
-
"Comma-separated sanitizers
|
|
33
|
+
"Comma-separated sanitizers: address, thread, leak, memory, undefined")
|
|
31
34
|
|
|
32
|
-
option(${PK_PREFIX}_HARDENING
|
|
33
|
-
option(${PK_PREFIX}_COVERAGE
|
|
34
|
-
option(${PK_PREFIX}_REPRODUCIBLE "Strip build paths out of binaries"
|
|
35
|
-
option(${PK_PREFIX}_LTO
|
|
36
|
-
option(${PK_PREFIX}_CCACHE
|
|
37
|
-
option(${PK_PREFIX}_REDUCE_SIZE
|
|
35
|
+
option(${PK_PREFIX}_HARDENING "Compile and link with hardening flags" ON)
|
|
36
|
+
option(${PK_PREFIX}_COVERAGE "Instrument for coverage" OFF)
|
|
37
|
+
option(${PK_PREFIX}_REPRODUCIBLE "Strip build paths out of binaries" OFF)
|
|
38
|
+
option(${PK_PREFIX}_LTO "Enable interprocedural optimization" OFF)
|
|
39
|
+
option(${PK_PREFIX}_CCACHE "Use ccache or sccache when one is installed" ON)
|
|
40
|
+
option(${PK_PREFIX}_REDUCE_SIZE "Strip dead code and unroll loops" ON)
|
|
38
41
|
|
|
39
42
|
add_library(${_pk_target} INTERFACE)
|
|
40
43
|
add_library(${PROJECT_NAME}::options ALIAS ${_pk_target})
|
|
41
44
|
set_target_properties(${_pk_target} PROPERTIES EXPORT_NAME options)
|
|
42
45
|
|
|
43
46
|
set(_pk_gnu_ids "GNU,Clang,AppleClang,IntelLLVM")
|
|
44
|
-
|
|
45
|
-
"$<OR:$<COMPILE_LANG_AND_ID:C,${_pk_gnu_ids}
|
|
47
|
+
string(CONCAT _pk_gnu_like
|
|
48
|
+
"$<OR:$<COMPILE_LANG_AND_ID:C,${_pk_gnu_ids}>,"
|
|
49
|
+
"$<COMPILE_LANG_AND_ID:CXX,${_pk_gnu_ids}>>")
|
|
46
50
|
set(_pk_msvc
|
|
47
51
|
"$<OR:$<COMPILE_LANG_AND_ID:C,MSVC>,$<COMPILE_LANG_AND_ID:CXX,MSVC>>")
|
|
48
52
|
|
|
49
|
-
if(
|
|
53
|
+
if(CMAKE_${_pk_main_lang}_COMPILER_FRONTEND_VARIANT STREQUAL "GNU")
|
|
50
54
|
set(${PK_PREFIX}_COMPILER_LIKE_GNU ON CACHE INTERNAL "")
|
|
51
55
|
set(${PK_PREFIX}_COMPILER_IS_MSVC OFF CACHE INTERNAL "")
|
|
52
56
|
set(_pk_compiler "${_pk_gnu_like}")
|
|
53
|
-
elseif(
|
|
57
|
+
elseif(CMAKE_${_pk_main_lang}_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
|
|
54
58
|
set(${PK_PREFIX}_COMPILER_LIKE_GNU OFF CACHE INTERNAL "")
|
|
55
59
|
set(${PK_PREFIX}_COMPILER_IS_MSVC ON CACHE INTERNAL "")
|
|
56
60
|
set(_pk_compiler "${_pk_msvc}")
|
|
57
61
|
else()
|
|
58
62
|
message(FATAL_ERROR
|
|
59
|
-
"Unsupported compiler front-end:
|
|
63
|
+
"Unsupported compiler front-end: "
|
|
64
|
+
"${CMAKE_${_pk_main_lang}_COMPILER_FRONTEND_VARIANT}")
|
|
60
65
|
endif()
|
|
61
66
|
|
|
62
67
|
if(${PK_PREFIX}_SANITIZE)
|
|
@@ -110,14 +115,16 @@ macro(pk_add_options_target)
|
|
|
110
115
|
"${PK_PREFIX}_HAS_SANITIZE_${${PK_PREFIX}_SANITIZE}" _pk_sanitize_probe)
|
|
111
116
|
|
|
112
117
|
set(CMAKE_REQUIRED_LINK_OPTIONS "${_pk_sanitize_flag}")
|
|
113
|
-
|
|
118
|
+
check_compiler_flag(${_pk_main_lang} "${_pk_sanitize_flag}"
|
|
119
|
+
${_pk_sanitize_probe})
|
|
114
120
|
unset(CMAKE_REQUIRED_LINK_OPTIONS)
|
|
115
121
|
|
|
116
122
|
if(NOT ${_pk_sanitize_probe})
|
|
117
|
-
if(MINGW AND
|
|
123
|
+
if(MINGW AND CMAKE_${_pk_main_lang}_COMPILER_ID STREQUAL "GNU")
|
|
118
124
|
message(FATAL_ERROR
|
|
119
125
|
"Windows/MinGW has no sanitizer runtimes for Windows targets. "
|
|
120
|
-
"Use Clang (pacman -S mingw-w64-ucrt-x86_64-clang) or build under
|
|
126
|
+
"Use Clang (pacman -S mingw-w64-ucrt-x86_64-clang) or build under "
|
|
127
|
+
"WSL.")
|
|
121
128
|
else()
|
|
122
129
|
message(FATAL_ERROR
|
|
123
130
|
"This toolchain cannot build with ${_pk_sanitize_flag}; the runtime "
|
|
@@ -128,10 +135,10 @@ macro(pk_add_options_target)
|
|
|
128
135
|
if(${PK_PREFIX}_COMPILER_IS_MSVC)
|
|
129
136
|
foreach(_pk_lang IN ITEMS C CXX)
|
|
130
137
|
foreach(_pk_config RELEASE RELWITHDEBINFO MINSIZEREL)
|
|
131
|
-
set(
|
|
132
|
-
string(REPLACE "/O2" "/O2 /Oy-" ${
|
|
133
|
-
string(REPLACE "/O1" "/O1 /Oy-" ${
|
|
134
|
-
string(REPLACE "/Oy- /Oy-" "/Oy-" ${
|
|
138
|
+
set(_pk_var CMAKE_${_pk_lang}_FLAGS_${_pk_config})
|
|
139
|
+
string(REPLACE "/O2" "/O2 /Oy-" ${_pk_var} "${${_pk_var}}")
|
|
140
|
+
string(REPLACE "/O1" "/O1 /Oy-" ${_pk_var} "${${_pk_var}}")
|
|
141
|
+
string(REPLACE "/Oy- /Oy-" "/Oy-" ${_pk_var} "${${_pk_var}}")
|
|
135
142
|
endforeach()
|
|
136
143
|
endforeach()
|
|
137
144
|
endif()
|
|
@@ -141,10 +148,13 @@ macro(pk_add_options_target)
|
|
|
141
148
|
|
|
142
149
|
if(${PK_PREFIX}_HARDENING)
|
|
143
150
|
if(${PK_PREFIX}_COMPILER_LIKE_GNU)
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
151
|
+
foreach(_pk_flag IN ITEMS
|
|
152
|
+
-fstack-protector-strong
|
|
153
|
+
-fstack-clash-protection
|
|
154
|
+
-fcf-protection=full
|
|
155
|
+
-ftrivial-auto-var-init=zero)
|
|
156
|
+
pk_try_compile_option(${_pk_target} "${_pk_compiler}" ${_pk_flag})
|
|
157
|
+
endforeach()
|
|
148
158
|
|
|
149
159
|
target_compile_definitions(${_pk_target} INTERFACE
|
|
150
160
|
"$<$<COMPILE_LANG_AND_ID:CXX,${_pk_gnu_ids}>:_GLIBCXX_ASSERTIONS>")
|
|
@@ -163,10 +173,11 @@ macro(pk_add_options_target)
|
|
|
163
173
|
endif()
|
|
164
174
|
|
|
165
175
|
if(NOT ${PK_PREFIX}_SANITIZE)
|
|
176
|
+
set(_pk_release "$<NOT:$<CONFIG:Debug>>")
|
|
177
|
+
set(_pk_msvc_cxx "$<COMPILE_LANG_AND_ID:CXX,MSVC>")
|
|
166
178
|
target_compile_definitions(${_pk_target} INTERFACE
|
|
167
|
-
"$<$<AND:${_pk_gnu_like}
|
|
168
|
-
|
|
169
|
-
"$<$<AND:$<COMPILE_LANG_AND_ID:CXX,MSVC>,$<NOT:$<CONFIG:Debug>>>:_SECURE_SCL=1>")
|
|
179
|
+
"$<$<AND:${_pk_gnu_like},${_pk_release}>:_FORTIFY_SOURCE=3>"
|
|
180
|
+
"$<$<AND:${_pk_msvc_cxx},${_pk_release}>:_SECURE_SCL=1>")
|
|
170
181
|
endif()
|
|
171
182
|
|
|
172
183
|
message(STATUS "${PROJECT_NAME}: hardening enabled")
|