Commit f935c9fcc0b964b23d2e67b62820528768b203c5

Authored by Jay Berkenbilt
1 parent 6434e09d

Replace JetBrains-specific cmake profiles with CMakePresets.json

Plus sneak in some spell checks
.gitignore
@@ -7,3 +7,8 @@ appimage/build @@ -7,3 +7,8 @@ appimage/build
7 .cache 7 .cache
8 /html 8 /html
9 Doxyfile 9 Doxyfile
  10 +/CMakeUserPresets.json
  11 +/compile_commands.json
  12 +
  13 +# ./Testing is created if you run ctest from the wrong place.
  14 +/Testing
.idea/.gitignore
@@ -7,3 +7,5 @@ @@ -7,3 +7,5 @@
7 /dataSources/ 7 /dataSources/
8 /dataSources.local.xml 8 /dataSources.local.xml
9 /inspectionProfiles 9 /inspectionProfiles
  10 +# We use CMakePresets.json. Don't check in cmake profiles.
  11 +/cmake.xml
.idea/cmake.xml deleted
1 -<?xml version="1.0" encoding="UTF-8"?>  
2 -<project version="4">  
3 - <component name="CMakeSharedSettings">  
4 - <configurations>  
5 - <configuration PROFILE_NAME="Maintainer" ENABLED="true" CONFIG_NAME="RelWithDebInfo" GENERATION_OPTIONS="-DMAINTAINER_MODE=ON -DBUILD_STATIC_LIBS=OFF" />  
6 - <configuration PROFILE_NAME="Windows" ENABLED="true" CONFIG_NAME="RelWithDebInfo" TOOLCHAIN_NAME="Visual Studio" GENERATION_OPTIONS="-DBUILD_SHARED_LIBS=OFF" />  
7 - </configurations>  
8 - </component>  
9 -</project>  
10 \ No newline at end of file 0 \ No newline at end of file
CMakePresets.json 0 → 100644
  1 +{
  2 + "version": 3,
  3 + "cmakeMinimumRequired": {
  4 + "major": 3,
  5 + "minor": 19,
  6 + "patch": 0
  7 + },
  8 + "configurePresets": [
  9 + {
  10 + "name": "base-config",
  11 + "hidden": true,
  12 + "description": "Common base settings",
  13 + "binaryDir": "${sourceDir}/cmake-build-${presetName}",
  14 + "cacheVariables": {
  15 + "CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
  16 + }
  17 + },
  18 + {
  19 + "name": "base-debug",
  20 + "hidden": true,
  21 + "inherits": "base-config",
  22 + "description": "Base settings for debug builds",
  23 + "cacheVariables": {
  24 + "CMAKE_BUILD_TYPE": "Debug",
  25 + "BUILD_SHARED_LIBS": "OFF"
  26 + }
  27 + },
  28 + {
  29 + "name": "base-unix",
  30 + "hidden": true,
  31 + "inherits": "base-config",
  32 + "description": "Base settings for Linux & macOS",
  33 + "condition": {
  34 + "type": "anyOf",
  35 + "conditions": [
  36 + {
  37 + "type": "equals",
  38 + "lhs": "${hostSystemName}",
  39 + "rhs": "Linux"
  40 + },
  41 + {
  42 + "type": "equals",
  43 + "lhs": "${hostSystemName}",
  44 + "rhs": "Darwin"
  45 + }
  46 + ]
  47 + },
  48 + "generator": "Ninja"
  49 + },
  50 + {
  51 + "name": "base-msvc",
  52 + "hidden": true,
  53 + "inherits": "base-config",
  54 + "description": "Base settings for Windows using MSVC",
  55 + "environment": {
  56 + "TOOLCHAIN_NAME": "Visual Studio"
  57 + },
  58 + "condition": {
  59 + "type": "equals",
  60 + "lhs": "${hostSystemName}",
  61 + "rhs": "Windows"
  62 + }
  63 + },
  64 + {
  65 + "name": "base-maintainer",
  66 + "hidden": true,
  67 + "displayName": "Base settings for maintainer mode",
  68 + "description": "Unix Maintainer build",
  69 + "inherits": "base-unix",
  70 + "cacheVariables": {
  71 + "MAINTAINER_MODE": "ON",
  72 + "BUILD_STATIC_LIBS": "OFF"
  73 + }
  74 + },
  75 + {
  76 + "name": "maintainer",
  77 + "displayName": "Maintainer",
  78 + "description": "Unix Maintainer build",
  79 + "inherits": "base-maintainer",
  80 + "cacheVariables": {
  81 + "CMAKE_BUILD_TYPE": "RelWithDebInfo"
  82 + }
  83 + },
  84 + {
  85 + "name": "maintainer-debug",
  86 + "displayName": "Maintainer (debug)",
  87 + "description": "Unix Maintainer build",
  88 + "inherits": [
  89 + "base-maintainer",
  90 + "base-debug"
  91 + ],
  92 + "cacheVariables": {
  93 + "BUILD_STATIC_LIBS": "ON"
  94 + }
  95 + },
  96 + {
  97 + "name": "maintainer-coverage",
  98 + "displayName": "Maintainer (coverage)",
  99 + "description": "Unix Maintainer build",
  100 + "inherits": "maintainer-debug",
  101 + "cacheVariables": {
  102 + "ENABLE_COVERAGE": "ON"
  103 + }
  104 + },
  105 + {
  106 + "name": "maintainer-profile",
  107 + "displayName": "Maintainer (profile)",
  108 + "description": "Unix Maintainer build",
  109 + "inherits": "maintainer-debug",
  110 + "environment": {
  111 + "CFLAGS": "-pg",
  112 + "CXXFLAGS": "-pg",
  113 + "LDFLAGS": "-pg"
  114 + }
  115 + },
  116 + {
  117 + "name": "debug",
  118 + "displayName": "Debug",
  119 + "description": "Debug build",
  120 + "inherits": "base-config",
  121 + "cacheVariables": {
  122 + "CMAKE_BUILD_TYPE": "Debug"
  123 + }
  124 + },
  125 + {
  126 + "name": "release",
  127 + "displayName": "Release",
  128 + "description": "Release build",
  129 + "inherits": "base-config",
  130 + "cacheVariables": {
  131 + "CMAKE_BUILD_TYPE": "Release"
  132 + }
  133 + },
  134 + {
  135 + "name": "sanitizers",
  136 + "displayName": "Unix + clang sanitizers",
  137 + "description": "Debug build with AddressSanitizer enabled",
  138 + "inherits": [
  139 + "base-unix",
  140 + "debug"
  141 + ],
  142 + "environment": {
  143 + "CFLAGS": "-fsanitize=address -fsanitize=undefined",
  144 + "CXXFLAGS": "-fsanitize=address -fsanitize=undefined",
  145 + "LDFLAGS": "-fsanitize=address -fsanitize=undefined",
  146 + "CC": "clang",
  147 + "CXX": "clang++"
  148 + },
  149 + "cacheVariables": {
  150 + "MAINTAINER_MODE": "ON",
  151 + "BUILD_SHARED_LIBS": "OFF",
  152 + "REQUIRE_CRYPTO_OPENSSL": "ON",
  153 + "REQUIRE_CRYPTO_GNUTLS": "ON",
  154 + "ENABLE_QTC": "ON"
  155 + }
  156 + },
  157 + {
  158 + "name": "msvc",
  159 + "displayName": "Windows/MSVC",
  160 + "description": "Visual Studio release with debug info build",
  161 + "inherits": [
  162 + "base-msvc"
  163 + ],
  164 + "cacheVariables": {
  165 + "CMAKE_BUILD_TYPE": "RelWithDebInfo",
  166 + "BUILD_SHARED_LIBS": "OFF"
  167 + }
  168 + },
  169 + {
  170 + "name": "msvc-release",
  171 + "displayName": "Windows/MSVC Release",
  172 + "description": "Visual Studio release build",
  173 + "inherits": [
  174 + "base-msvc",
  175 + "release"
  176 + ]
  177 + }
  178 + ],
  179 + "buildPresets": [
  180 + {
  181 + "name": "maintainer",
  182 + "configurePreset": "maintainer",
  183 + "description": "Run build for maintainer mode"
  184 + }
  185 + ],
  186 + "testPresets": [
  187 + {
  188 + "name": "maintainer",
  189 + "configurePreset": "maintainer",
  190 + "description": "Run default tests for maintainer mode",
  191 + "output": {
  192 + "verbosity": "verbose"
  193 + }
  194 + },
  195 + {
  196 + "name": "msvc",
  197 + "configurePreset": "msvc",
  198 + "description": "Run default tests for msvc",
  199 + "output": {
  200 + "verbosity": "verbose"
  201 + }
  202 + }
  203 + ]
  204 +}
README-maintainer.md
@@ -30,70 +30,85 @@ separate mechanism for tracking changes. @@ -30,70 +30,85 @@ separate mechanism for tracking changes.
30 30
31 **Remember to check pull requests as well as issues in github.** 31 **Remember to check pull requests as well as issues in github.**
32 32
33 -Include `-DCMAKE_EXPORT_COMPILE_COMMANDS=ON` with cmake if using emacs lsp mode.  
34 -  
35 -Default: 33 +Run `cmake --list-presets` to see available cmake presets. Routine maintainer development can be
36 34
37 ``` 35 ```
38 -cmake -DMAINTAINER_MODE=ON -DBUILD_STATIC_LIBS=OFF \  
39 - -DCMAKE_BUILD_TYPE=RelWithDebInfo .. 36 +cmake --preset maintainer
  37 +cmake --build --preset maintainer
  38 +ctest --preset maintainer
40 ``` 39 ```
41 40
42 -Debugging: 41 +See [CMakePresets.json](CMakePresets.json) for additional presets. Reminders about presets:
  42 +* You can override/enhance configure presets, e.g., `cmake --preset maintainer -DCMAKE_BUILD_TYPE=Release`
  43 +* You can pass flags to ctest, e.g., `ctest --preset maintainer -R zlib-flate`.
  44 +* You can't override the build directory for build and test presets, but you _can_ override the
  45 + directory for configure presets and then run `cmake --build build-dir` and `ctest` manually, as
  46 + shown below.
  47 +* The base configuration includes `-DCMAKE_EXPORT_COMPILE_COMMANDS=ON`, which is useful for LSP mode
  48 + in C++. This is harmless in environments where it's not needed. You may need to make a symlink
  49 + from compile_commands.json to the one in whichever build directory you are using.
  50 +* If you have common configurations you'd like to see, pull requests are welcome, but
  51 + `CMakeUserPresets.json` is your friend. You can copy or inherit from CMakeUserPresets.json for
  52 + your own use. Note that CMakeUserPresets.json is not part of the stable API. We reserve the right
  53 + to modify these presets in a non-compatible fashion at any time without regard to qpdf version
  54 + numbers, but we should mention changes in the release notes.
  55 +* Study the CMakePresets.json file for details on how these are implemented.
  56 +
  57 +See also ./build-scripts for other ways to run the build for different configurations.
  58 +
  59 +### Useful build examples
  60 +
  61 +To run a maintainer build in release mode and run only the unicode-filenames test, you could run
43 62
44 ``` 63 ```
45 -cmake -DMAINTAINER_MODE=ON -DBUILD_SHARED_LIBS=OFF \  
46 - -DCMAKE_BUILD_TYPE=Debug .. 64 +cmake --preset maintainer -DCMAKE_BUILD_TYPE=Release
  65 +cmake --build --preset maintainer
  66 +TESTS=unicode-filenames ctest --preset maintainer -R qpdf
47 ``` 67 ```
48 68
49 -Profiling: 69 +To run a maintainer build in release mode in a _different directory_ and run only the
  70 +unicode-filenames test, you could run the following. Trying to override the directory on the command
  71 +line of `cmake --build` or `ctest` in conjunction with `--preset` may silently ignore the directory
  72 +override, and you may not get what you think you are getting.
50 73
51 ``` 74 ```
52 -CFLAGS=-pg LDFLAGS=-pg \  
53 - cmake -DMAINTAINER_MODE=ON -DBUILD_SHARED_LIBS=OFF \  
54 - -DCMAKE_BUILD_TYPE=Debug .. 75 +cmake --preset maintainer -DCMAKE_BUILD_TYPE=Release -B cmake-build-release
  76 +cmake --build cmake-build-release
  77 +TESTS=unicode-filenames ctest --verbose --test-dir cmake-build-release -R qpdf
55 ``` 78 ```
56 79
57 -Then run `gprof gmon.out`. Note that gmon.out is not cumulative. 80 +### Profiling
58 81
59 -Coverage: 82 +When running with the `maintainer-profile` preset (or any time you run profiling), run `gprof
  83 +gmon.out`. Note that gmon.out is not cumulative.
60 84
61 -```  
62 -cmake -DMAINTAINER_MODE=ON -DBUILD_SHARED_LIBS=OFF \  
63 - -DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE=ON..  
64 -``` 85 +### Coverage
65 86
66 -Then, from the build directory, run the test suite (`ctest --verbose`) followed by 87 +When running with the `maintainer-coverage` preset, after running tests:
67 ``` 88 ```
68 gcovr -r .. --html --html-details -o coverage-report.html 89 gcovr -r .. --html --html-details -o coverage-report.html
69 ``` 90 ```
70 91
71 Note that, in early 2024, branch coverage information is not very accurate with C++. 92 Note that, in early 2024, branch coverage information is not very accurate with C++.
72 93
73 -Memory checks: 94 +### Sanitizers/Memory Checks
74 95
75 -Note: if clang++ fails to create output, it may be necessary to install a specific version of  
76 -libstdc++-dev. For example, with clang++ version 20 on Ubuntu 24.04, `clang++ -v` indicates the  
77 -selected GCC installation is 14, so it is necessary to install `libstdc++-14-dev`. 96 +If `clang++` fails to create output during configuration, it may be necessary to install a specific
  97 +version of libstdc++-dev. For example, with clang++ version 20 on Ubuntu 24.04, `clang++ -v`
  98 +indicates the selected GCC installation is 14, so it is necessary to install `libstdc++-14-dev`.
78 99
79 -```  
80 -CFLAGS="-fsanitize=address -fsanitize=undefined" \  
81 - CXXFLAGS="-fsanitize=address -fsanitize=undefined" \  
82 - LDFLAGS="-fsanitize=address -fsanitize=undefined" \  
83 - CC=clang CXX=clang++ \  
84 - cmake -DMAINTAINER_MODE=ON -DBUILD_SHARED_LIBS=OFF \  
85 - -DCMAKE_BUILD_TYPE=Debug ..  
86 -``` 100 +### Windows
87 101
88 -Windows: 102 +You can use this for command-line builds, which does a bit more than the presets. The msvc presets
  103 +are known to work in CLion if the environment is set up as described in
  104 +[README-windows.md](./README-windows.md), but for regular command-line builds (and CI), continue to
  105 +use `cmake-win` from inside a build directory. Look at `build-scripts/build-windows` to see how this
  106 +is used.
89 107
90 ``` 108 ```
91 ../cmake-win {mingw|msvc} maint 109 ../cmake-win {mingw|msvc} maint
92 ``` 110 ```
93 111
94 -See ./build-scripts for other ways to run the build for different  
95 -configurations.  
96 -  
97 ## VERSIONS 112 ## VERSIONS
98 113
99 * The version number on the main branch is whatever the version would 114 * The version number on the main branch is whatever the version would
cSpell.json
@@ -612,6 +612,7 @@ @@ -612,6 +612,7 @@
612 "stampfile", 612 "stampfile",
613 "stamppdf", 613 "stamppdf",
614 "startxref", 614 "startxref",
  615 + "startxrefs",
615 "stdexcept", 616 "stdexcept",
616 "stdint", 617 "stdint",
617 "stdiofile", 618 "stdiofile",
manual/release-notes.rst
@@ -21,7 +21,7 @@ more detail. @@ -21,7 +21,7 @@ more detail.
21 integer object. Previously the method returned false if the first 21 integer object. Previously the method returned false if the first
22 dictionary object was not a linearization parameter dictionary. 22 dictionary object was not a linearization parameter dictionary.
23 23
24 - - Fix parsing of object streams containing objects not seperated by 24 + - Fix parsing of object streams containing objects not separated by
25 white-space. Pre-2020 editions of the PDF specification incorrectly 25 white-space. Pre-2020 editions of the PDF specification incorrectly
26 stated that white-space was required between objects. qpdf relied on this 26 stated that white-space was required between objects. qpdf relied on this
27 when parsing object streams. 27 when parsing object streams.
@@ -39,6 +39,16 @@ more detail. @@ -39,6 +39,16 @@ more detail.
39 - There have been further enhancements to how files with damaged xref 39 - There have been further enhancements to how files with damaged xref
40 tables are recovered. 40 tables are recovered.
41 41
  42 + - Build changes
  43 +
  44 + - The file ``.idea/cmake.xml`` has been removed. Instead of
  45 + shipping with some CMake profiles in the CLion-specific
  46 + configuration, we now include a ``CMakePresets.json``. There is
  47 + information about using it in ``README-maintainer.md``. For
  48 + most users, running ``cmake`` in the normal way is fine.
  49 + Suggestions are welcome. None of the official builds use cmake
  50 + presets at the time of initial introduction.
  51 +
42 - Other changes 52 - Other changes
43 53
44 - The parsing of object streams including the creation of error/warning 54 - The parsing of object streams including the creation of error/warning