Skip to content

Commit

Permalink
Merge pull request #3795 from Saverio976/doc/cmake-fetch-content
Browse files Browse the repository at this point in the history
Add doc on how to use it with cmake FetchContent
  • Loading branch information
Cyan4973 authored Oct 31, 2023
2 parents 7567769 + 3c3845b commit 81fdca0
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions build/cmake/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,38 @@ cmake -DZSTD_BUILD_TESTS=ON -DZSTD_LEGACY_SUPPORT=OFF ..
make
```

### how to use it with CMake FetchContent

For all options available, you can see it on <https://github.com/facebook/zstd/blob/dev/build/cmake/lib/CMakeLists.txt>
```cmake
include(FetchContent)
set(ZSTD_BUILD_STATIC ON)
set(ZSTD_BUILD_SHARED OFF)
FetchContent_Declare(
zstd
URL "https://github.com/facebook/zstd/releases/download/v1.5.5/zstd-1.5.5.tar.gz"
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
SOURCE_SUBDIR build/cmake
)
FetchContent_MakeAvailable(zstd)
target_link_libraries(
${PROJECT_NAME}
PRIVATE
libzstd_static
)
# On windows and macos this is needed
target_include_directories(
${PROJECT_NAME}
PRIVATE
${zstd_SOURCE_DIR}/lib
)
```

### referring
[Looking for a 'cmake clean' command to clear up CMake output](https://stackoverflow.com/questions/9680420/looking-for-a-cmake-clean-command-to-clear-up-cmake-output)

Expand Down

0 comments on commit 81fdca0

Please sign in to comment.