-
Notifications
You must be signed in to change notification settings - Fork 268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CMake: enable building and installing as a library #311
Open
rouault
wants to merge
1
commit into
BinomialLLC:master
Choose a base branch
from
rouault:cmake
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@PACKAGE_INIT@ | ||
|
||
include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]") | ||
|
||
check_required_components(@PROJECT_NAME@) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying file COPYING-CMAKE-SCRIPTS or | ||
# https://cmake.org/licensing for details. | ||
|
||
#[=======================================================================[.rst: | ||
FindZSTD | ||
-------- | ||
|
||
Find the ZSTD library | ||
|
||
Zstandard C/C++ library is built with CMake. So this find module | ||
should be removed when ZStandard library export cmake config files | ||
as distribution. Unfortunately ZStandard does not export it, | ||
we need to prepare find module. | ||
see. https://gitlab.kitware.com/cmake/cmake/-/issues/19405 | ||
|
||
IMPORTED targets | ||
^^^^^^^^^^^^^^^^ | ||
|
||
This module defines the following :prop_tgt:`IMPORTED` target: ``ZSTD::zstd`` | ||
|
||
Result variables | ||
^^^^^^^^^^^^^^^^ | ||
|
||
This module will set the following variables if found: | ||
|
||
``ZSTD_INCLUDE_DIRS`` - where to find zstd.h, etc. | ||
``ZSTD_LIBRARIES`` - the libraries to link against to use ZSTD. | ||
``ZSTD_VERSION`` - version of the ZSTD library found | ||
``ZSTD_FOUND`` - TRUE if found | ||
|
||
:: | ||
|
||
``ZSTD_VERSION_MAJOR`` - The major version of zstd | ||
``ZSTD_VERSION_MINOR`` - The minor version of zstd | ||
``ZSTD_VERSION_RELEASE`` - The release version of zstd | ||
|
||
#]=======================================================================] | ||
|
||
find_package(PkgConfig) | ||
pkg_check_modules(PC_ZSTD QUIET libzstd) | ||
|
||
find_path( | ||
ZSTD_INCLUDE_DIR | ||
NAMES zstd.h | ||
PATHS ${PC_ZSTD_INCLUDE_DIRS} | ||
) | ||
find_library( | ||
ZSTD_LIBRARY | ||
NAMES zstd zstd_static NAMES_PER_DIR | ||
PATHS ${PC_ZSTD_LIBRARY_DIRS} | ||
) | ||
|
||
# Extract version information from the header file | ||
if(EXISTS "${ZSTD_INCLUDE_DIR}/zstd.h") | ||
file(STRINGS "${ZSTD_INCLUDE_DIR}/zstd.h" | ||
_ZSTD_VERSION_MAJOR REGEX "^#define ZSTD_VERSION_MAJOR") | ||
string(REGEX MATCH "[0-9]+" ZSTD_VERSION_MAJOR ${_ZSTD_VERSION_MAJOR}) | ||
file(STRINGS "${ZSTD_INCLUDE_DIR}/zstd.h" | ||
_ZSTD_VERSION_MINOR REGEX "^#define ZSTD_VERSION_MINOR") | ||
string(REGEX MATCH "[0-9]+" ZSTD_VERSION_MINOR ${_ZSTD_VERSION_MINOR} ) | ||
file(STRINGS "${ZSTD_INCLUDE_DIR}/zstd.h" | ||
_ZSTD_VERSION_RELEASE REGEX "^#define ZSTD_VERSION_RELEASE") | ||
string(REGEX MATCH "[0-9]+" ZSTD_VERSION_RELEASE ${_ZSTD_VERSION_RELEASE} ) | ||
set(ZSTD_VERSION ${ZSTD_VERSION_MAJOR}.${ZSTD_VERSION_MINOR}.${ZSTD_VERSION_RELEASE}) | ||
endif() | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args( | ||
ZSTD | ||
FOUND_VAR ZSTD_FOUND | ||
REQUIRED_VARS ZSTD_LIBRARY ZSTD_INCLUDE_DIR | ||
VERSION_VAR ZSTD_VERSION | ||
HANDLE_COMPONENTS) | ||
mark_as_advanced(ZSTD_INCLUDE_DIR ZSTD_LIBRARY) | ||
|
||
include(FeatureSummary) | ||
set_package_properties( | ||
ZSTD PROPERTIES | ||
DESCRIPTION "Zstandard - Fast real-time compression algorithm" | ||
URL "https://github.com/facebook/zstd") | ||
|
||
if(ZSTD_FOUND) | ||
set(ZSTD_INCLUDE_DIRS ${ZSTD_INCLUDE_DIR}) | ||
set(ZSTD_LIBRARIES ${ZSTD_LIBRARY}) | ||
set(ZSTD_DEFINITIONS ${PC_ZSTD_CFLAGS_OTHER}) | ||
set(ZSTD_TARGET ZSTD::zstd) | ||
if(NOT TARGET ${ZSTD_TARGET}) | ||
add_library(${ZSTD_TARGET} UNKNOWN IMPORTED) | ||
set_target_properties(${ZSTD_TARGET} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${ZSTD_INCLUDE_DIR}) | ||
if(EXISTS "${ZSTD_LIBRARY}") | ||
set_target_properties(${ZSTD_TARGET} PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" | ||
IMPORTED_LOCATION "${ZSTD_LIBRARY}") | ||
endif() | ||
endif() | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant,
facebook/zstd
installs the exported targets