Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
cmake/install: add THRUST_ENABLE_INSTALL_RULES option
Browse files Browse the repository at this point in the history
cmake/install: mv ThrustAddSubdir handling to after project()

We want to add the option to install in this case, which requires
the paths set by project()

thrust: separate out determination of whether Thrust is top-level project

This determines whether an install target will be provided. If Thrust is
built as top-level project, the install target will be provided by default,
as before.

If Thrust is built as a sub-project, the install target will, by default,
not be provided, again maintaining existing behavior.

So what's new here is that via this option a downstream project can enable
install of thrust if it is used via `add_subdirectory`.

Update CONTRIBUTING.md with new CMake option docs.
  • Loading branch information
germasch authored and alliepiper committed Oct 5, 2020
1 parent e68ea76 commit 7714602
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
28 changes: 20 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
# 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}")
include(cmake/ThrustAddSubdir.cmake)
return()
endif()

# 3.15 is the minimum.
# 3.17 for nvc++/Feta
# 3.18 for C++17 + CUDA
Expand All @@ -18,12 +11,31 @@ 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()

option(THRUST_ENABLE_INSTALL_RULES "Enable installation of Thrust" ${THRUST_TOPLEVEL_PROJECT})
if (THRUST_ENABLE_INSTALL_RULES)
include(cmake/ThrustInstallRules.cmake)
endif()

# Support adding Thrust to a parent project via add_subdirectory.
# See examples/cmake/add_subdir/CMakeLists.txt for details.
if (NOT THRUST_TOPLEVEL_PROJECT)
include(cmake/ThrustAddSubdir.cmake)
return()
endif()

include(cmake/AppendOptionIfAvailable.cmake)

include(cmake/ThrustBuildCompilerTargets.cmake)
include(cmake/ThrustBuildTargetList.cmake)
include(cmake/ThrustMultiConfig.cmake)
include(cmake/ThrustInstallRules.cmake)
include(cmake/ThrustUtilities.cmake)

option(THRUST_ENABLE_HEADER_TESTING "Test that all public headers compile." "ON")
Expand Down
6 changes: 6 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ The CMake options are divided into these categories:
- `THRUST_ENABLE_EXAMPLE_FILECHECK={ON, OFF}`
- Enable validation of example outputs using the LLVM FileCheck utility.
Default is `OFF`.
- `THRUST_ENABLE_INSTALL_RULES={ON, OFF}`
- If true, installation rules will be generated for thrust. Default is `ON`.

## Single Config CMake Options

Expand Down Expand Up @@ -391,6 +393,10 @@ The CMake options are divided into these categories:
simultaneously.
- CUB configurations will be generated for each C++ dialect targeted by
the current Thrust build.
- `THRUST_INSTALL_CUB_HEADERS={ON, OFF}`
- If enabled, the CUB project's headers will be installed through Thrust's
installation rules. Default is `ON`.
- This option depends on `THRUST_ENABLE_INSTALL_RULES`.
- `THRUST_ENABLE_COMPUTE_XX={ON, OFF}`
- Controls the targeted CUDA architecture(s)
- Multiple options may be selected when using NVCC as the CUDA compiler.
Expand Down

0 comments on commit 7714602

Please sign in to comment.