Skip to content

Commit

Permalink
Use CMake PROJECT_IS_TOP_LEVEL variable instead of hack
Browse files Browse the repository at this point in the history
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 <noreply@github.com>
  • Loading branch information
alanxz authored Jan 4, 2024
1 parent bbdf682 commit b3ad8f2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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 "
Expand Down

0 comments on commit b3ad8f2

Please sign in to comment.