cmake: Emulate PROJECT_IS_TOP_LEVEL for CMake<3.21

This commit is contained in:
Hennadii Stepanov 2023-04-20 23:12:28 +01:00
parent a6f4bcf6e1
commit 162608cc98
No known key found for this signature in database
GPG Key ID: 410108112E7EA81F

View File

@ -12,6 +12,18 @@ endif()
# backwards-compatible and therefore at most increase the minor version. # backwards-compatible and therefore at most increase the minor version.
project(libsecp256k1 VERSION 0.3.2 LANGUAGES C) project(libsecp256k1 VERSION 0.3.2 LANGUAGES C)
if(CMAKE_VERSION VERSION_LESS 3.21)
get_directory_property(parent_directory PARENT_DIRECTORY)
if(parent_directory)
set(PROJECT_IS_TOP_LEVEL OFF CACHE INTERNAL "Emulates CMake 3.21+ behavior.")
set(${PROJECT_NAME}_IS_TOP_LEVEL OFF CACHE INTERNAL "Emulates CMake 3.21+ behavior.")
else()
set(PROJECT_IS_TOP_LEVEL ON CACHE INTERNAL "Emulates CMake 3.21+ behavior.")
set(${PROJECT_NAME}_IS_TOP_LEVEL ON CACHE INTERNAL "Emulates CMake 3.21+ behavior.")
endif()
unset(parent_directory)
endif()
# The library version is based on libtool versioning of the ABI. The set of # The library version is based on libtool versioning of the ABI. The set of
# rules for updating the version can be found here: # rules for updating the version can be found here:
# https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html # https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html