Skip to content

Commit 629ff48

Browse files
committed
[cmake] root wrapper
allow the existence of a `CMakeLists.txt` file at root, for easier integration with other projects expecting this file at root. Existing integration point, within `build/cmake/`, still works as expected.
1 parent a8f732e commit 629ff48

File tree

4 files changed

+56
-28
lines changed

4 files changed

+56
-28
lines changed

.gitignore

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,6 @@ zstdmt
2222
*.out
2323
*.app
2424

25-
# Test artefacts
26-
tmp*
27-
*.zst
28-
*.zstd
29-
dictionary.
30-
dictionary
31-
NUL
32-
cmakebuild/
33-
install/
34-
3525
# Build artefacts
3626
contrib/linux-kernel/linux/
3727
projects/
@@ -40,6 +30,17 @@ bin/
4030
buck-out/
4131
build-*
4232
*.gcda
33+
cmakebuild/
34+
cmake-build/
35+
36+
# Test artefacts
37+
tmp*
38+
*.zst
39+
*.zstd
40+
dictionary.
41+
dictionary
42+
NUL
43+
install/
4344

4445
# IDE
4546
.clang_complete

CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
cmake_minimum_required(VERSION 3.10)
2+
3+
# Thin wrapper so `cmake -S .` behaves like `cmake -S build/cmake`.
4+
# Policy lives in build/cmake; keep parent project language-less.
5+
project(zstd-superbuild LANGUAGES NONE)
6+
7+
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
8+
message(FATAL_ERROR "In-source builds are not supported. Specify -B <build-dir>.")
9+
endif()
10+
11+
add_subdirectory(build/cmake)

README.md

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -120,20 +120,20 @@ Dictionary gains are mostly effective in the first few KB. Then, the compression
120120

121121
## Build instructions
122122

123-
`make` is the officially maintained build system of this project.
124-
All other build systems are "compatible" and 3rd-party maintained,
125-
they may feature small differences in advanced options.
126-
When your system allows it, prefer using `make` to build `zstd` and `libzstd`.
123+
`make` is the main build system of this project.
124+
It is the reference, and other build systems are periodically updated to stay compatible.
125+
However, small drifts and feature differences can be present, since perfect synchronization is difficult.
126+
For this reason, when your build system allows it, prefer employing `make`.
127127

128128
### Makefile
129129

130130
Assuming your system supports standard `make` (or `gmake`),
131-
invoking `make` in root directory will generate `zstd` cli in root directory.
132-
It will also create `libzstd` into `lib/`.
131+
just invoking `make` in root directory generates `zstd` cli at root,
132+
and also generates `libzstd` into `lib/`.
133133

134134
Other standard targets include:
135-
- `make install` : create and install zstd cli, library and man pages
136-
- `make check` : create and run `zstd`, test its behavior on local platform
135+
- `make install` : install zstd cli, library and man pages
136+
- `make check` : run `zstd`, test its essential behavior on local platform
137137

138138
The `Makefile` follows the [GNU Standard Makefile conventions](https://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html),
139139
allowing staged install, standard compilation flags, directory variables and command variables.
@@ -144,9 +144,16 @@ and in [`programs/README.md`](programs/README.md#compilation-variables) for the
144144

145145
### cmake
146146

147-
A `cmake` project generator is provided within `build/cmake`.
148-
It can generate Makefiles or other build scripts
149-
to create `zstd` binary, and `libzstd` dynamic and static libraries.
147+
A `cmake` project generator is available for generating Makefiles or other build scripts
148+
to create the `zstd` binary as well as `libzstd` dynamic and static libraries.
149+
The repository root now contains a minimal `CMakeLists.txt` that forwards to `build/cmake`,
150+
so you can configure the project with a standard `cmake -S .` invocation,
151+
while the historical `cmake -S build/cmake` entry point remains fully supported.
152+
153+
```bash
154+
cmake -S . -B build-cmake
155+
cmake --build build-cmake
156+
```
150157

151158
By default, `CMAKE_BUILD_TYPE` is set to `Release`.
152159

@@ -156,7 +163,7 @@ By default, `CMAKE_BUILD_TYPE` is set to `Release`.
156163
To perform a Fat/Universal2 build and install use the following commands:
157164

158165
```bash
159-
cmake -B build-cmake-debug -S build/cmake -G Ninja -DCMAKE_OSX_ARCHITECTURES="x86_64;x86_64h;arm64"
166+
cmake -S . -B build-cmake-debug -G Ninja -DCMAKE_OSX_ARCHITECTURES="x86_64;x86_64h;arm64"
160167
cd build-cmake-debug
161168
ninja
162169
sudo ninja install
@@ -198,10 +205,11 @@ If the version is out of date, please [create an issue or pull request](https://
198205
### Visual Studio (Windows)
199206

200207
Going into `build` directory, you will find additional possibilities:
201-
- Projects for Visual Studio 2005, 2008 and 2010.
208+
- Projects for Visual Studio 2008 and 2010.
202209
+ VS2010 project is compatible with VS2012, VS2013, VS2015 and VS2017.
203210
- Automated build scripts for Visual compiler by [@KrzysFR](https://github.com/KrzysFR), in `build/VS_scripts`,
204211
which will build `zstd` cli and `libzstd` library without any need to open Visual Studio solution.
212+
- It is now recommended to generate Visual Studio solutions from `cmake`
205213

206214
### Buck
207215

@@ -210,7 +218,7 @@ The output binary will be in `buck-out/gen/programs/`.
210218

211219
### Bazel
212220

213-
You easily can integrate zstd into your Bazel project by using the module hosted on the [Bazel Central Repository](https://registry.bazel.build/modules/zstd).
221+
You can integrate zstd into your Bazel project by using the module hosted on the [Bazel Central Repository](https://registry.bazel.build/modules/zstd).
214222

215223
## Testing
216224

@@ -221,9 +229,9 @@ For information on CI testing, please refer to `TESTING.md`.
221229

222230
## Status
223231

224-
Zstandard is currently deployed within Facebook and many other large cloud infrastructures.
225-
It is run continuously to compress large amounts of data in multiple formats and use cases.
226-
Zstandard is considered safe for production environments.
232+
Zstandard is deployed within Meta and many other large cloud infrastructures,
233+
to compress humongous amounts of data in various formats and use cases.
234+
It is also continuously fuzzed for security issues by Google's [oss-fuzz](https://github.com/google/oss-fuzz/tree/master/projects/zstd) program.
227235

228236
## License
229237

@@ -232,6 +240,5 @@ Zstandard is dual-licensed under [BSD](LICENSE) OR [GPLv2](COPYING).
232240
## Contributing
233241

234242
The `dev` branch is the one where all contributions are merged before reaching `release`.
235-
If you plan to propose a patch, please commit into the `dev` branch, or its own feature branch.
236243
Direct commit to `release` are not permitted.
237244
For more information, please read [CONTRIBUTING](CONTRIBUTING.md).

build/cmake/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ variables.
77

88
## How to build
99

10+
You can configure the project from the repository root thanks to the forwarding
11+
`CMakeLists.txt`:
12+
```sh
13+
cmake -S . -B build-cmake
14+
cmake --build build-cmake
15+
```
16+
The historical workflow that starts configuration from `build/cmake` continues
17+
to work as described below.
18+
1019
As cmake doesn't support command like `cmake clean`, it's recommended to perform an "out of source build".
1120
To do this, you can create a new directory and build in it:
1221
```sh

0 commit comments

Comments
 (0)