From 9fda8b1d4d4cbe0087dab8a14a0cff4fa52c92f2 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Sat, 26 Sep 2020 13:45:11 -0400 Subject: [PATCH] thrust: separate out determination of whether Thrust is top-level project --- CMakeLists.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ac8d15058..b1f4ae7e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,9 +11,17 @@ endif() project(Thrust NONE) +# Determine whether Thrust is the top-level project or included into +# another project via add_subdirectory() +if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_LIST_DIR}") + set(THRUST_TOPLEVEL_PROJECT ON) +else() + set(THRUST_TOPLEVEL_PROJECT OFF) +endif() + # Support adding Thrust to a parent project via add_subdirectory. # See examples/cmake/add_subdir/CMakeLists.txt for details. -if (NOT "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_LIST_DIR}") +if (NOT THRUST_TOPLEVEL_PROJECT) include(cmake/ThrustAddSubdir.cmake) return() endif()