Skip to content

Commit 162608c

Browse files
committed
cmake: Emulate PROJECT_IS_TOP_LEVEL for CMake<3.21
1 parent a6f4bcf commit 162608c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

CMakeLists.txt

+12
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@ endif()
1212
# backwards-compatible and therefore at most increase the minor version.
1313
project(libsecp256k1 VERSION 0.3.2 LANGUAGES C)
1414

15+
if(CMAKE_VERSION VERSION_LESS 3.21)
16+
get_directory_property(parent_directory PARENT_DIRECTORY)
17+
if(parent_directory)
18+
set(PROJECT_IS_TOP_LEVEL OFF CACHE INTERNAL "Emulates CMake 3.21+ behavior.")
19+
set(${PROJECT_NAME}_IS_TOP_LEVEL OFF CACHE INTERNAL "Emulates CMake 3.21+ behavior.")
20+
else()
21+
set(PROJECT_IS_TOP_LEVEL ON CACHE INTERNAL "Emulates CMake 3.21+ behavior.")
22+
set(${PROJECT_NAME}_IS_TOP_LEVEL ON CACHE INTERNAL "Emulates CMake 3.21+ behavior.")
23+
endif()
24+
unset(parent_directory)
25+
endif()
26+
1527
# The library version is based on libtool versioning of the ABI. The set of
1628
# rules for updating the version can be found here:
1729
# https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html

0 commit comments

Comments
 (0)