From b3ad8f21ff244dda6149403d50cad41682af3ac9 Mon Sep 17 00:00:00 2001 From: Alan Antonuk Date: Thu, 4 Jan 2024 01:37:35 +0000 Subject: [PATCH] Use CMake PROJECT_IS_TOP_LEVEL variable instead of hack Use the PROJECT_IS_TOP_LEVEL variable to determine whether the root CMakeLists.txt file is the top-level file or a subproject of a larger project. This is more readable than the hack that it replaces. Signed-off-by: GitHub --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cea53cea..99b62216 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -130,7 +130,7 @@ if (ENABLE_SSL_SUPPORT) cmake_dependent_option(ENABLE_SSL_ENGINE_API "Enable support for deprecated OpenSSL ENGINE feature" ON "HAS_OPENSSL_ENGINE" OFF) endif() -if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) +if(PROJECT_IS_TOP_LEVEL) include(CTest) endif() @@ -176,7 +176,7 @@ if(BUILD_TOOLS) add_subdirectory(tools) endif() -if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) +if(PROJECT_IS_TOP_LEVEL AND BUILD_TESTING) if (NOT BUILD_STATIC_LIBS) message(FATAL_ERROR "Tests can only be built against static libraries "