Skip to content
This repository was archived by the owner on Apr 19, 2023. It is now read-only.

Commit fd620a5

Browse files
Fix undefined PROJECT_IS_TOP_LEVEL for cmake <3.21
1 parent aeb2a3e commit fd620a5

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@ cmake_minimum_required(VERSION 3.15...3.23)
22

33
project(CmakeConfigPackageTests LANGUAGES CXX)
44

5+
# This variable is set by project() in CMake 3.21+
6+
string(
7+
COMPARE EQUAL
8+
"${CMAKE_SOURCE_DIR}"
9+
"${PROJECT_SOURCE_DIR}"
10+
PROJECT_IS_TOP_LEVEL)
11+
if(PROJECT_IS_TOP_LEVEL)
12+
# Consider the CTest module, which creates targets and options!
13+
# Only needed if you want to enable submissions to a CDash server.
14+
include(CTest)
15+
endif()
16+
517
# ---- Test as standalone project the exported config package ----
618

719
if(PROJECT_IS_TOP_LEVEL OR TEST_INSTALLED_VERSION)

0 commit comments

Comments
 (0)