-
Notifications
You must be signed in to change notification settings - Fork 758
Support adding Thrust to CMake projects with add_subdirectory
#976
Comments
cross referencing #981 |
The so far released versions contain a build system that is currently unsupported; the next Toolkit release should contain the new build system that is already available in master (and the maintenance branches here on Github). Why are you doing
you should be doing
|
@griwes Because Also, what you suggest breaks the transitivity of dependency, e.g., |
I don't follow.
The point about transitivity does seem fair to me, but |
This is a very common method, and works well in several cases, such as if you use git submodules to manage dependencies. Supporting it is not too hard, though it does take some care in setup. The problem with something like find_package is that it requires "installs", and it tends to touch things in a user's home directory. Since thrust is header-only, you can currently add this without using add_subdirectory (that's what I currently do) in a few lines, but it's much nicer and more consistent to do this will all dependencies. Many libraries now support that, like PyBind11. I would second making tests only build if this is the main project. |
@henryiii just to make sure I understand PyBind11's CMakeLists - the include directories attached to the interface library will be propagated to any library that "links" it? If that is so, I think we could do that. (The rest of this comment hinges on whether my understanding there is correct, regarding include paths, other compiler flags, and linker flags being attachable to that target.) (NB: this doesn't change my opinion that this feels like the wrong primitive for this purpose. The CMake community may disagree here, but if that is indeed the mechanism at work here, I'm rather concerned about the direction the CMake community is taking with the project and the recommended practices for it.) Nevertheless, I think that in such a situation I'd make tests and examples not optional, but not present at all, because I'd prefer to not have to think about name clashes with targets et al. Essentially, I'd insert a conditional
Does this sound sensible to everyone? |
@griwes, yes, that is correct. The general idea is that if you are careful, you can provide the exact same interface whether you install, just build, or use To do this, you should provide "Thrust::Thrust" or something similar as the external target. The namespace can be added by the target export; and for the An example of a library that does this already is VexCL: https://github.com/ddemidov/vexcl/blob/a0fe836ee70280b697bbabcaee7edd2fba8faac0/CMakeLists.txt#L189 . Note that this is using the old find_package method for the CUDA target. To see an example of what this looks like in practice in one of my projects: Note that fmtlib has added the more canonical So, in answer to your suggestion:
|
Not CUDA, because we do a lot of Thrust specific CUDA configuration, and I don't want the "proper" build system to be entangled with interface targets that we'd export. For instance, I imagine that not everyone wants to force the CUDA host compiler to be the exact same compiler as the C++ compiler ;) I guess I could put I would not export separate libraries for different targets. This is for at least three reasons:
I realize that this runs afoul of potential use-cases where people could have different parts of their project, built by a single build system, correctly use Thrust with different backends (i.e. never linking them together, or making sure that all Thrust symbols are hidden, etc.) - but since this sounds like a more expert thing to do to me, I think the added difficulty with shooting yourself in the foot by silently violating ODR is not entirely unwelcome. I'm not sure why I'd want to specify "no defines". It'd essentially be equivalent to "with defines, for host = CPP and device = CUDA", which would be the default anyway. I'm not sure I fully understand the Config file part yet; I'll try to get something along the lines of what I described above going within the next few of weeks (time permitting); hopefully then we can figure out all the details? @henryiii, since you seem to have a good grasp on this, my thinking is I'd create a PR here and ask you to review; does that sound good? |
@henryiii provides a very thorough explanation here. @griwes I only want to point out what you asked before about fetchcontent and add_subdirectory -- it's described here: https://github.com/Kitware/CMake/blob/e2d0aea2c734c8c5028f3573082e75bd157dbe72/Modules/FetchContent.cmake#L43-L58 |
@griwes, yes, I could do that. |
@griwes, here is a possible use that would be great to support (completely making up API here) set(THRUST_BACKEND ALL) # Enables search for all backends
include_subdirectory(thrust)
# Could also be find_package(thrust CONFIG) just as easily
# The following could even be wrapped into a function thrust_add_executables
add_executable(my_prog_omp myprog.cu)
set_source_files_properties(myprog.cu PROPERTIES LANGUAGE CXX)
target_link_libraries(my_prog_cuda PRIVATE Thrust::OMP)
if(TARGET Thrust::CUDA)
add_executable(my_prog_cuda myprog.cu)
target_link_libraries(my_prog_cuda PRIVATE Thrust::CUDA)
endif() Now multiple backends are built, allowing easy switching/testing/comparison. This is similar to how VecCL works, and was implemented in a proof of concept form for Hydra (which contains Thrust): https://github.com/CLIUtils/cmake/blob/master/AddHydra.cmake. |
I assume you could have |
Is there any update on this? |
I'll be addressing the issue in the title as part of the fix for #1159. From the discussion here, it seems like you folks may be interested in the new I think that should fulfill the usecases described in the above discussion. Take a look at the new |
@allisonvacanti I don't think I understand how #1159 is related to this because it seems to be about how to config the build for testing. A simple boolean switch is enough to exclude the tests for a build tree. |
https://github.com/thrust/thrust/blob/master/CMakeLists.txt#L88-L94
What I propose is: when a checkout of thrust is included via As a concrete example of how this would work I'll modify @henryiii's example:
#1159 is not directly related, but it's going to involve a significant refactoring of our build system that includes adding switches for tests, examples, and header-tests. This was just a heads up that we'll be adding the option through other work soon. |
Thank you @allisonvacanti for explaining! This makes more sense now. When should we expect this to be implemented? I am looking forward to trying it out. |
Should be ready in the next couple of weeks. I'm working on the multiconfig stuff now, once that's in good shape I'll just need to add a few bits to get |
Fixes NVIDIA#1159. Also fixes or works around these issues: - WAR NVIDIA#1167: Disable arches 53, 62, 72 by default. - Fixes NVIDIA#1168: Set RUN_SERIAL on OpenMP tests. - WAR ccache/ccache#598: nvcc flags `s/-Werror all-warnings/-Xcudafe --promote_warnings/g` - WAR NVIDIA#1174: remove warning promotion from tbb.cuda targets. - WAR NVIDIA#976: Add options to enable/disable tests, examples, header_tests: - THRUST_ENABLE_TESTING - THRUST_ENABLE_EXAMPLES - THRUST_ENABLE_HEADER_TESTING Summary: - Bump CMake to 3.15 - Needed for CUDA_COMPILER_ID generator expression. - Move testing related CMake code to `testing/CMakeLists.txt` - Move example related CMake code to `examples/CMakeLists.txt` - Move header testing related CMake code to `cmake/ThrustHeaderTesting.cmake` - Explicitly `include(cmake/*.cmake)` files rather than searching CMAKE_MODULE_PATH -- we only want to use the ones in the repo. - Added ThrustMultiConfig.cmake - Handle MultiConfig (and single config) logic. - Added ThrustBuildTargetList.cmake - Builds the THRUST_TARGETS list, which contains one interface target for each enabled host/device/dialect configuration. - Added ThrustBuildCompilerTargets.cmake - Move warning flag, etc setup into it, bind compile interfaces to targets instead of global variables. - Renamed common_variables.cmake to ThrustCommonVariables.cmake - Removed THRUST_TREAT_FILE_AS_CXX - This worked by setting a cmake SOURCE_FILE property, which no longer works since multiconfig may build the same source file with both CXX and CUDA. - Instead, the `.cu` files are wrapped in a `.cpp` file that does nothing but include the `.cu` file. The `.cpp` files are then added to the CXX targets as sources. - See `cmake/ThrustUtilities.cmake` for implementation.
Fixes NVIDIA#1159. Also fixes or works around these issues: - WAR NVIDIA#1167: Disable arches 53, 62, 72 by default. - Fixes NVIDIA#1168: Set RUN_SERIAL on OpenMP tests. - WAR ccache/ccache#598: nvcc flags `s/-Werror all-warnings/-Xcudafe --promote_warnings/g` - WAR NVIDIA#1174: remove warning promotion from tbb.cuda targets. - WAR NVIDIA#976: Add options to enable/disable tests, examples, header_tests: - THRUST_ENABLE_TESTING - THRUST_ENABLE_EXAMPLES - THRUST_ENABLE_HEADER_TESTING Summary: - Bump CMake to 3.15 - Needed for CUDA_COMPILER_ID generator expression. - Removed workarounds for older CMake versions. - Removed warning flag specific to for C++98. - Dialects are now configured through target properties. Add new THRUST_CPP_DIALECT option for single config mode, and remove logic that modified CMAKE_CXX_STANDARD and CMAKE_CUDA_STANDARD. - Move testing related CMake code to `testing/CMakeLists.txt` - Move example related CMake code to `examples/CMakeLists.txt` - Move header testing related CMake code to `cmake/ThrustHeaderTesting.cmake` - Move CUDA configuration logic to `cmake/ThrustCUDAConfig.cmake`. - Explicitly `include(cmake/*.cmake)` files rather than searching CMAKE_MODULE_PATH -- we only want to use the ones in the repo. - Added ThrustMultiConfig.cmake - Handle MultiConfig (and single config) logic. - Added ThrustBuildTargetList.cmake - Builds the THRUST_TARGETS list, which contains one interface target for each enabled host/device/dialect configuration. - Added ThrustBuildCompilerTargets.cmake - Move warning flag, etc setup into it, bind compile interfaces to targets instead of global variables. - Renamed common_variables.cmake to ThrustCommonVariables.cmake - Removed THRUST_TREAT_FILE_AS_CXX - This worked by setting a cmake SOURCE_FILE property, which no longer works since multiconfig may build the same source file with both CXX and CUDA. - Instead, the `.cu` files are wrapped in a `.cpp` file that does nothing but include the `.cu` file. The `.cpp` files are then added to the CXX targets as sources. - See `cmake/ThrustUtilities.cmake` for implementation. - Fix bug in thrust-config.cmake where an internal var was not cached as expected.
Fixes NVIDIA#1159. Also fixes or works around these issues: - WAR NVIDIA#1167: Disable arches 53, 62, 72 by default. - Fixes NVIDIA#1168: Set RUN_SERIAL on OpenMP tests. - WAR ccache/ccache#598: nvcc flags `s/-Werror all-warnings/-Xcudafe --promote_warnings/g` - WAR NVIDIA#1174: remove warning promotion from tbb.cuda targets. - WAR NVIDIA#976: Add options to enable/disable tests, examples, header_tests: - THRUST_ENABLE_TESTING - THRUST_ENABLE_EXAMPLES - THRUST_ENABLE_HEADER_TESTING Summary: - Bump CMake to 3.15 - Needed for CUDA_COMPILER_ID generator expression. - Removed workarounds for older CMake versions. - Removed warning flag specific to for C++98. - Dialects are now configured through target properties. Add new THRUST_CPP_DIALECT option for single config mode, and remove logic that modified CMAKE_CXX_STANDARD and CMAKE_CUDA_STANDARD. - Move testing related CMake code to `testing/CMakeLists.txt` - Move example related CMake code to `examples/CMakeLists.txt` - Move header testing related CMake code to `cmake/ThrustHeaderTesting.cmake` - Move CUDA configuration logic to `cmake/ThrustCUDAConfig.cmake`. - Explicitly `include(cmake/*.cmake)` files rather than searching CMAKE_MODULE_PATH -- we only want to use the ones in the repo. - Added ThrustMultiConfig.cmake - Handle MultiConfig (and single config) logic. - Added ThrustBuildTargetList.cmake - Builds the THRUST_TARGETS list, which contains one interface target for each enabled host/device/dialect configuration. - Added ThrustBuildCompilerTargets.cmake - Move warning flag, etc setup into it, bind compile interfaces to targets instead of global variables. - Renamed common_variables.cmake to ThrustCommonVariables.cmake - Removed THRUST_TREAT_FILE_AS_CXX - This worked by setting a cmake SOURCE_FILE property, which no longer works since multiconfig may build the same source file with both CXX and CUDA. - Instead, the `.cu` files are wrapped in a `.cpp` file that does nothing but include the `.cu` file. The `.cpp` files are then added to the CXX targets as sources. - See `cmake/ThrustUtilities.cmake` for implementation. - Fix bug in thrust-config.cmake where an internal var was not cached as expected.
Fixes NVIDIA#1159. Also fixes or works around these issues: - WAR NVIDIA#1167: Disable arches 53, 62, 72 by default. - Fixes NVIDIA#1168: Set RUN_SERIAL on OpenMP tests. - WAR ccache/ccache#598: nvcc flags `s/-Werror all-warnings/-Xcudafe --promote_warnings/g` - WAR NVIDIA#1174: remove warning promotion from tbb.cuda targets. - WAR NVIDIA#976: Add options to enable/disable tests, examples, header_tests: - THRUST_ENABLE_TESTING - THRUST_ENABLE_EXAMPLES - THRUST_ENABLE_HEADER_TESTING Summary: - Bump CMake to 3.15 - Needed for CUDA_COMPILER_ID generator expression. - Removed workarounds for older CMake versions. - Removed warning flag specific to for C++98. - Dialects are now configured through target properties. Add new THRUST_CPP_DIALECT option for single config mode, and remove logic that modified CMAKE_CXX_STANDARD and CMAKE_CUDA_STANDARD. - Move testing related CMake code to `testing/CMakeLists.txt` - Move example related CMake code to `examples/CMakeLists.txt` - Move header testing related CMake code to `cmake/ThrustHeaderTesting.cmake` - Move CUDA configuration logic to `cmake/ThrustCUDAConfig.cmake`. - Explicitly `include(cmake/*.cmake)` files rather than searching CMAKE_MODULE_PATH -- we only want to use the ones in the repo. - Added ThrustMultiConfig.cmake - Handle MultiConfig (and single config) logic. - Added ThrustBuildTargetList.cmake - Builds the THRUST_TARGETS list, which contains one interface target for each enabled host/device/dialect configuration. - Added ThrustBuildCompilerTargets.cmake - Move warning flag, etc setup into it, bind compile interfaces to targets instead of global variables. - Renamed common_variables.cmake to ThrustCommonVariables.cmake - Removed THRUST_TREAT_FILE_AS_CXX - This worked by setting a cmake SOURCE_FILE property, which no longer works since multiconfig may build the same source file with both CXX and CUDA. - Instead, the `.cu` files are wrapped in a `.cpp` file that does nothing but include the `.cu` file. The `.cpp` files are then added to the CXX targets as sources. - See `cmake/ThrustUtilities.cmake` for implementation. - Fix bug in thrust-config.cmake where an internal var was not cached as expected.
Fixes NVIDIA#1159. Also fixes or works around these issues: - WAR NVIDIA#1167: Disable arches 53, 62, 72 by default. - Fixes NVIDIA#1168: Set RUN_SERIAL on OpenMP tests. - WAR ccache/ccache#598: nvcc flags `s/-Werror all-warnings/-Xcudafe --promote_warnings/g` - WAR NVIDIA#1174: remove warning promotion from tbb.cuda targets. - WAR NVIDIA#976: Add options to enable/disable tests, examples, header_tests: - THRUST_ENABLE_TESTING - THRUST_ENABLE_EXAMPLES - THRUST_ENABLE_HEADER_TESTING Summary: - Bump CMake to 3.15 - Needed for CUDA_COMPILER_ID generator expression. - Removed workarounds for older CMake versions. - Removed warning flag specific to for C++98. - Dialects are now configured through target properties. Add new THRUST_CPP_DIALECT option for single config mode, and remove logic that modified CMAKE_CXX_STANDARD and CMAKE_CUDA_STANDARD. - Move testing related CMake code to `testing/CMakeLists.txt` - Move example related CMake code to `examples/CMakeLists.txt` - Move header testing related CMake code to `cmake/ThrustHeaderTesting.cmake` - Move CUDA configuration logic to `cmake/ThrustCUDAConfig.cmake`. - Explicitly `include(cmake/*.cmake)` files rather than searching CMAKE_MODULE_PATH -- we only want to use the ones in the repo. - Added ThrustMultiConfig.cmake - Handle MultiConfig (and single config) logic. - Added ThrustBuildTargetList.cmake - Builds the THRUST_TARGETS list, which contains one interface target for each enabled host/device/dialect configuration. - Added ThrustBuildCompilerTargets.cmake - Move warning flag, etc setup into it, bind compile interfaces to targets instead of global variables. - Renamed common_variables.cmake to ThrustCommonVariables.cmake - Removed THRUST_TREAT_FILE_AS_CXX - This worked by setting a cmake SOURCE_FILE property, which no longer works since multiconfig may build the same source file with both CXX and CUDA. - Instead, the `.cu` files are wrapped in a `.cpp` file that does nothing but include the `.cu` file. The `.cpp` files are then added to the CXX targets as sources. - See `cmake/ThrustUtilities.cmake` for implementation. - Fix bug in thrust-config.cmake where an internal var was not cached as expected.
Fixes NVIDIA#1159. Also fixes or works around these issues: - WAR NVIDIA#1167: Disable arches 53, 62, 72 by default. - Fixes NVIDIA#1168: Set RUN_SERIAL on OpenMP tests. - WAR ccache/ccache#598: nvcc flags `s/-Werror all-warnings/-Xcudafe --promote_warnings/g` - WAR NVIDIA#1174: remove warning promotion from tbb.cuda targets. - WAR NVIDIA#976: Add options to enable/disable tests, examples, header_tests: - THRUST_ENABLE_TESTING - THRUST_ENABLE_EXAMPLES - THRUST_ENABLE_HEADER_TESTING Summary: - Bump CMake to 3.15 - Needed for CUDA_COMPILER_ID generator expression. - Removed workarounds for older CMake versions. - Removed warning flag specific to for C++98. - Dialects are now configured through target properties. Add new THRUST_CPP_DIALECT option for single config mode, and remove logic that modified CMAKE_CXX_STANDARD and CMAKE_CUDA_STANDARD. - Move testing related CMake code to `testing/CMakeLists.txt` - Move example related CMake code to `examples/CMakeLists.txt` - Move header testing related CMake code to `cmake/ThrustHeaderTesting.cmake` - Move CUDA configuration logic to `cmake/ThrustCUDAConfig.cmake`. - Explicitly `include(cmake/*.cmake)` files rather than searching CMAKE_MODULE_PATH -- we only want to use the ones in the repo. - Added ThrustMultiConfig.cmake - Handle MultiConfig (and single config) logic. - Added ThrustBuildTargetList.cmake - Builds the THRUST_TARGETS list, which contains one interface target for each enabled host/device/dialect configuration. - Added ThrustBuildCompilerTargets.cmake - Move warning flag, etc setup into it, bind compile interfaces to targets instead of global variables. - Renamed common_variables.cmake to ThrustCommonVariables.cmake - Removed THRUST_TREAT_FILE_AS_CXX - This worked by setting a cmake SOURCE_FILE property, which no longer works since multiconfig may build the same source file with both CXX and CUDA. - Instead, the `.cu` files are wrapped in a `.cpp` file that does nothing but include the `.cu` file. The `.cpp` files are then added to the CXX targets as sources. - See `cmake/ThrustUtilities.cmake` for implementation. - Fix bug in thrust-config.cmake where an internal var was not cached as expected.
Fixes NVIDIA#1159. Also fixes or works around these issues: - WAR NVIDIA#1167: Disable arches 53, 62, 72 by default. - Fixes NVIDIA#1168: Set RUN_SERIAL on OpenMP tests. - WAR ccache/ccache#598: nvcc flags `s/-Werror all-warnings/-Xcudafe --promote_warnings/g` - WAR NVIDIA#1174: remove warning promotion from tbb.cuda targets. - WAR NVIDIA#976: Add options to enable/disable tests, examples, header_tests: - THRUST_ENABLE_TESTING - THRUST_ENABLE_EXAMPLES - THRUST_ENABLE_HEADER_TESTING Summary: - Bump CMake to 3.15 - Needed for CUDA_COMPILER_ID generator expression. - Removed workarounds for older CMake versions. - Removed warning flag specific to for C++98. - Dialects are now configured through target properties. Add new THRUST_CPP_DIALECT option for single config mode, and remove logic that modified CMAKE_CXX_STANDARD and CMAKE_CUDA_STANDARD. - Move testing related CMake code to `testing/CMakeLists.txt` - Move example related CMake code to `examples/CMakeLists.txt` - Move header testing related CMake code to `cmake/ThrustHeaderTesting.cmake` - Move CUDA configuration logic to `cmake/ThrustCUDAConfig.cmake`. - Explicitly `include(cmake/*.cmake)` files rather than searching CMAKE_MODULE_PATH -- we only want to use the ones in the repo. - Added ThrustMultiConfig.cmake - Handle MultiConfig (and single config) logic. - Added ThrustBuildTargetList.cmake - Builds the THRUST_TARGETS list, which contains one interface target for each enabled host/device/dialect configuration. - Added ThrustBuildCompilerTargets.cmake - Move warning flag, etc setup into it, bind compile interfaces to targets instead of global variables. - Renamed common_variables.cmake to ThrustCommonVariables.cmake - Removed THRUST_TREAT_FILE_AS_CXX - This worked by setting a cmake SOURCE_FILE property, which no longer works since multiconfig may build the same source file with both CXX and CUDA. - Instead, the `.cu` files are wrapped in a `.cpp` file that does nothing but include the `.cu` file. The `.cpp` files are then added to the CXX targets as sources. - See `cmake/ThrustUtilities.cmake` for implementation. - Fix bug in thrust-config.cmake where an internal var was not cached as expected.
Fixes NVIDIA#1159. Also fixes or works around these issues: - WAR NVIDIA#1167: Disable arches 53, 62, 72 by default. - Fixes NVIDIA#1168: Set RUN_SERIAL on OpenMP tests. - WAR ccache/ccache#598: nvcc flags `s/-Werror all-warnings/-Xcudafe --promote_warnings/g` - WAR NVIDIA#1174: remove warning promotion from tbb.cuda targets. - WAR NVIDIA#976: Add options to enable/disable tests, examples, header_tests: - THRUST_ENABLE_TESTING - THRUST_ENABLE_EXAMPLES - THRUST_ENABLE_HEADER_TESTING Summary: - Bump CMake to 3.15 - Needed for CUDA_COMPILER_ID generator expression. - Removed workarounds for older CMake versions. - Removed warning flag specific to for C++98. - Dialects are now configured through target properties. Add new THRUST_CPP_DIALECT option for single config mode, and remove logic that modified CMAKE_CXX_STANDARD and CMAKE_CUDA_STANDARD. - Move testing related CMake code to `testing/CMakeLists.txt` - Move example related CMake code to `examples/CMakeLists.txt` - Move header testing related CMake code to `cmake/ThrustHeaderTesting.cmake` - Move CUDA configuration logic to `cmake/ThrustCUDAConfig.cmake`. - Explicitly `include(cmake/*.cmake)` files rather than searching CMAKE_MODULE_PATH -- we only want to use the ones in the repo. - Added ThrustMultiConfig.cmake - Handle MultiConfig (and single config) logic. - Added ThrustBuildTargetList.cmake - Builds the THRUST_TARGETS list, which contains one interface target for each enabled host/device/dialect configuration. - Added ThrustBuildCompilerTargets.cmake - Move warning flag, etc setup into it, bind compile interfaces to targets instead of global variables. - Renamed common_variables.cmake to ThrustCommonVariables.cmake - Removed THRUST_TREAT_FILE_AS_CXX - This worked by setting a cmake SOURCE_FILE property, which no longer works since multiconfig may build the same source file with both CXX and CUDA. - Instead, the `.cu` files are wrapped in a `.cpp` file that does nothing but include the `.cu` file. The `.cpp` files are then added to the CXX targets as sources. - See `cmake/ThrustUtilities.cmake` for implementation. - Fix bug in thrust-config.cmake where an internal var was not cached as expected.
Fixes NVIDIA#1159. Also fixes or works around these issues: - WAR NVIDIA#1167: Disable arches 53, 62, 72 by default. - Fixes NVIDIA#1168: Set RUN_SERIAL on OpenMP tests. - WAR ccache/ccache#598: nvcc flags `s/-Werror all-warnings/-Xcudafe --promote_warnings/g` - WAR NVIDIA#1174: remove warning promotion from tbb.cuda targets. - WAR NVIDIA#976: Add options to enable/disable tests, examples, header_tests: - THRUST_ENABLE_TESTING - THRUST_ENABLE_EXAMPLES - THRUST_ENABLE_HEADER_TESTING Summary: - Bump CMake requirement to 3.15 - Needed for CUDA_COMPILER_ID generator expression. - Removed workarounds for older CMake versions. - Removed warning flag specific to for C++98. - Dialects are now configured through target properties. Add new THRUST_CPP_DIALECT option for single config mode, and remove logic that modified CMAKE_CXX_STANDARD and CMAKE_CUDA_STANDARD. - Move testing related CMake code to `testing/CMakeLists.txt` - Move example related CMake code to `examples/CMakeLists.txt` - Move header testing related CMake code to `cmake/ThrustHeaderTesting.cmake` - Move CUDA configuration logic to `cmake/ThrustCUDAConfig.cmake`. - Explicitly `include(cmake/*.cmake)` files rather than searching CMAKE_MODULE_PATH -- we only want to use the ones in the repo. - Added ThrustMultiConfig.cmake - Handle MultiConfig (and single config) logic. - Added ThrustBuildTargetList.cmake - Builds the THRUST_TARGETS list, which contains one interface target for each enabled host/device/dialect configuration. - Added ThrustBuildCompilerTargets.cmake - Move warning flag, etc setup into it, bind compile interfaces to targets instead of global variables. - Renamed common_variables.cmake to ThrustCommonVariables.cmake - Removed THRUST_TREAT_FILE_AS_CXX - This worked by setting a cmake SOURCE_FILE property, which no longer works since multiconfig may build the same source file with both CXX and CUDA. - Instead, the `.cu` files are wrapped in a `.cpp` file that does nothing but include the `.cu` file. The `.cpp` files are then added to the CXX targets as sources. - See `cmake/ThrustUtilities.cmake` for implementation. - Fix bug in thrust-config.cmake where an internal var was not cached as expected.
Fixes NVIDIA#1159. Also fixes or works around these issues: - WAR NVIDIA#1167: Disable arches 53, 62, 72 by default. - Fixes NVIDIA#1168: Set RUN_SERIAL on OpenMP tests. - WAR ccache/ccache#598: nvcc flags `s/-Werror all-warnings/-Xcudafe --promote_warnings/g` - WAR NVIDIA#1174: remove warning promotion from tbb.cuda targets. - WAR NVIDIA#976: Add options to enable/disable tests, examples, header_tests: - THRUST_ENABLE_TESTING - THRUST_ENABLE_EXAMPLES - THRUST_ENABLE_HEADER_TESTING Summary: - Bump CMake requirement to 3.15 - Needed for CUDA_COMPILER_ID generator expression. - Removed workarounds for older CMake versions. - Removed warning flag specific to for C++98. - Dialects are now configured through target properties. Add new THRUST_CPP_DIALECT option for single config mode, and remove logic that modified CMAKE_CXX_STANDARD and CMAKE_CUDA_STANDARD. - Move testing related CMake code to `testing/CMakeLists.txt` - Move example related CMake code to `examples/CMakeLists.txt` - Move header testing related CMake code to `cmake/ThrustHeaderTesting.cmake` - Move CUDA configuration logic to `cmake/ThrustCUDAConfig.cmake`. - Explicitly `include(cmake/*.cmake)` files rather than searching CMAKE_MODULE_PATH -- we only want to use the ones in the repo. - Added ThrustMultiConfig.cmake - Handle MultiConfig (and single config) logic. - Added ThrustBuildTargetList.cmake - Builds the THRUST_TARGETS list, which contains one interface target for each enabled host/device/dialect configuration. - Added ThrustBuildCompilerTargets.cmake - Move warning flag, etc setup into it, bind compile interfaces to targets instead of global variables. - Renamed common_variables.cmake to ThrustCommonVariables.cmake - Removed THRUST_TREAT_FILE_AS_CXX - This worked by setting a cmake SOURCE_FILE property, which no longer works since multiconfig may build the same source file with both CXX and CUDA. - Instead, the `.cu` files are wrapped in a `.cpp` file that does nothing but include the `.cu` file. The `.cpp` files are then added to the CXX targets as sources. - See `cmake/ThrustUtilities.cmake` for implementation. - Fix bug in thrust-config.cmake where an internal var was not cached as expected.
Fixes NVIDIA#1159. Also fixes or works around these issues: - WAR NVIDIA#1167: Disable arches 53, 62, 72 by default. - Fixes NVIDIA#1168: Set RUN_SERIAL on OpenMP tests. - WAR ccache/ccache#598: nvcc flags `s/-Werror all-warnings/-Xcudafe --promote_warnings/g` - WAR NVIDIA#1174: remove warning promotion from tbb.cuda targets. - WAR NVIDIA#976: Add options to enable/disable tests, examples, header_tests: - THRUST_ENABLE_TESTING - THRUST_ENABLE_EXAMPLES - THRUST_ENABLE_HEADER_TESTING Summary: - Bump CMake requirement to 3.15 - Needed for CUDA_COMPILER_ID generator expression. - Removed workarounds for older CMake versions. - Removed warning flag specific to for C++98. - Dialects are now configured through target properties. Add new THRUST_CPP_DIALECT option for single config mode, and remove logic that modified CMAKE_CXX_STANDARD and CMAKE_CUDA_STANDARD. - Move testing related CMake code to `testing/CMakeLists.txt` - Move example related CMake code to `examples/CMakeLists.txt` - Move header testing related CMake code to `cmake/ThrustHeaderTesting.cmake` - Move CUDA configuration logic to `cmake/ThrustCUDAConfig.cmake`. - Explicitly `include(cmake/*.cmake)` files rather than searching CMAKE_MODULE_PATH -- we only want to use the ones in the repo. - Added ThrustMultiConfig.cmake - Handle MultiConfig (and single config) logic. - Added ThrustBuildTargetList.cmake - Builds the THRUST_TARGETS list, which contains one interface target for each enabled host/device/dialect configuration. - Added ThrustBuildCompilerTargets.cmake - Move warning flag, etc setup into it, bind compile interfaces to targets instead of global variables. - Renamed common_variables.cmake to ThrustCommonVariables.cmake - Removed THRUST_TREAT_FILE_AS_CXX - This worked by setting a cmake SOURCE_FILE property, which no longer works since multiconfig may build the same source file with both CXX and CUDA. - Instead, the `.cu` files are wrapped in a `.cpp` file that does nothing but include the `.cu` file. The `.cpp` files are then added to the CXX targets as sources. - See `cmake/ThrustUtilities.cmake` for implementation. - Fix bug in thrust-config.cmake where an internal var was not cached as expected.
Fixes NVIDIA#1159. Also fixes or works around these issues: - WAR NVIDIA#1167: Disable arches 53, 62, 72 by default. - Fixes NVIDIA#1168: Set RUN_SERIAL on OpenMP and TBB tests. - WAR ccache/ccache#598: nvcc flags `s/-Werror all-warnings/-Xcudafe --promote_warnings/g` - WAR NVIDIA#1174: remove warning promotion from tbb.cuda targets. - WAR NVIDIA#976: Add options to enable/disable tests, examples, header_tests: - THRUST_ENABLE_TESTING - THRUST_ENABLE_EXAMPLES - THRUST_ENABLE_HEADER_TESTING - THRUST_ENABLE_EXAMPLE_FILECHECK Summary: - Bump CMake requirement to 3.15 - Needed for CUDA_COMPILER_ID generator expression. - Removed workarounds for older CMake versions. - Removed warning flag specific to for C++98. - Dialects are now configured through target properties. Add new THRUST_CPP_DIALECT option for single config mode, and remove logic that modified CMAKE_CXX_STANDARD and CMAKE_CUDA_STANDARD. - Move testing related CMake code to `testing/CMakeLists.txt` - Move example related CMake code to `examples/CMakeLists.txt` - Move header testing related CMake code to `cmake/ThrustHeaderTesting.cmake` - Move CUDA configuration logic to `cmake/ThrustCUDAConfig.cmake`. - Explicitly `include(cmake/*.cmake)` files rather than searching CMAKE_MODULE_PATH -- we only want to use the ones in the repo. - Added ThrustMultiConfig.cmake - Handle MultiConfig (and single config) logic. - Added ThrustBuildTargetList.cmake - Builds the THRUST_TARGETS list, which contains one interface target for each enabled host/device/dialect configuration. - Added ThrustBuildCompilerTargets.cmake - Move warning flag, etc setup into it, bind compile interfaces to targets instead of global variables. - Removed common_variables.cmake and simplified FileCheck hooks. - Set THRUST_ENABLE_EXAMPLE_FILECHECK to turn on FileCheck validation - Automatically detect and set THRUST_FILECHECK_EXECUTABLE if installed and filechecking is enabled. - Removed THRUST_TREAT_FILE_AS_CXX - This worked by setting a cmake SOURCE_FILE property, which no longer works since multiconfig may build the same source file with both CXX and CUDA. - Instead, the `.cu` files are wrapped in a `.cpp` file that does nothing but include the `.cu` file. The `.cpp` files are then added to the CXX targets as sources. - See `cmake/ThrustUtilities.cmake` for implementation. - Fix bug in thrust-config.cmake where an internal var was not cached as expected.
Fixes NVIDIA#1159. Also fixes or works around these issues: - WAR NVIDIA#1167: - Disable arches 53, 62, 72 for RDC-required tests, print warning - Error when ENABLE_RDC for tests/examples is set with a no-RDC arch. - Fixes NVIDIA#1168: Set RUN_SERIAL on OpenMP and TBB tests. - WAR ccache/ccache#598: nvcc flags `s/-Werror all-warnings/-Xcudafe --promote_warnings/g` - WAR NVIDIA#1174: remove warning promotion from tbb.cuda targets. - WAR NVIDIA#976: Add options to enable/disable tests, examples, header_tests: - THRUST_ENABLE_TESTING - THRUST_ENABLE_EXAMPLES - THRUST_ENABLE_HEADER_TESTING Summary: - Bump CMake requirement to 3.15 - Needed for CUDA_COMPILER_ID generator expression. - Removed workarounds for older CMake versions. - Removed warning flag specific to for C++98. - Dialects are now configured through target properties. Add new THRUST_CPP_DIALECT option for single config mode, and remove logic that modified CMAKE_CXX_STANDARD and CMAKE_CUDA_STANDARD. - Move testing related CMake code to `testing/CMakeLists.txt` - Move example related CMake code to `examples/CMakeLists.txt` - Move header testing related CMake code to `cmake/ThrustHeaderTesting.cmake` - Move CUDA configuration logic to `cmake/ThrustCUDAConfig.cmake`. - Explicitly `include(cmake/*.cmake)` files rather than searching CMAKE_MODULE_PATH -- we only want to use the ones in the repo. - Added ThrustMultiConfig.cmake - Handle MultiConfig (and single config) logic. - Added ThrustBuildTargetList.cmake - Builds the THRUST_TARGETS list, which contains one interface target for each enabled host/device/dialect configuration. - Added ThrustBuildCompilerTargets.cmake - Move warning flag, etc setup into it, bind compile interfaces to targets instead of global variables. - Renamed common_variables.cmake to ThrustCommonVariables.cmake - Removed THRUST_TREAT_FILE_AS_CXX - This worked by setting a cmake SOURCE_FILE property, which no longer works since multiconfig may build the same source file with both CXX and CUDA. - Instead, the `.cu` files are wrapped in a `.cpp` file that does nothing but include the `.cu` file. The `.cpp` files are then added to the CXX targets as sources. - See `cmake/ThrustUtilities.cmake` for implementation. - Fix bug in thrust-config.cmake where an internal var was not cached as expected.
Fixes #1159. Also fixes or works around these issues: - WAR #1167: - Disable arches 53, 62, 72 for RDC-required tests, print warning - Error when ENABLE_RDC for tests/examples is set with a no-RDC arch. - Fixes #1168: Set RUN_SERIAL on OpenMP and TBB tests. - WAR ccache/ccache#598: nvcc flags `s/-Werror all-warnings/-Xcudafe --promote_warnings/g` - WAR #1174: remove warning promotion from tbb.cuda targets. - WAR #976: Add options to enable/disable tests, examples, header_tests: - THRUST_ENABLE_TESTING - THRUST_ENABLE_EXAMPLES - THRUST_ENABLE_HEADER_TESTING Summary: - Bump CMake requirement to 3.15 - Needed for CUDA_COMPILER_ID generator expression. - Removed workarounds for older CMake versions. - Removed warning flag specific to for C++98. - Dialects are now configured through target properties. Add new THRUST_CPP_DIALECT option for single config mode, and remove logic that modified CMAKE_CXX_STANDARD and CMAKE_CUDA_STANDARD. - Move testing related CMake code to `testing/CMakeLists.txt` - Move example related CMake code to `examples/CMakeLists.txt` - Move header testing related CMake code to `cmake/ThrustHeaderTesting.cmake` - Move CUDA configuration logic to `cmake/ThrustCUDAConfig.cmake`. - Explicitly `include(cmake/*.cmake)` files rather than searching CMAKE_MODULE_PATH -- we only want to use the ones in the repo. - Added ThrustMultiConfig.cmake - Handle MultiConfig (and single config) logic. - Added ThrustBuildTargetList.cmake - Builds the THRUST_TARGETS list, which contains one interface target for each enabled host/device/dialect configuration. - Added ThrustBuildCompilerTargets.cmake - Move warning flag, etc setup into it, bind compile interfaces to targets instead of global variables. - Renamed common_variables.cmake to ThrustCommonVariables.cmake - Removed THRUST_TREAT_FILE_AS_CXX - This worked by setting a cmake SOURCE_FILE property, which no longer works since multiconfig may build the same source file with both CXX and CUDA. - Instead, the `.cu` files are wrapped in a `.cpp` file that does nothing but include the `.cu` file. The `.cpp` files are then added to the CXX targets as sources. - See `cmake/ThrustUtilities.cmake` for implementation. - Fix bug in thrust-config.cmake where an internal var was not cached as expected.
add_subdirectory
#1184 makes all build targets toggle-able via CMake variables:
I've updated the title of this issue to reflect the work that remains. |
See issue NVIDIA#976. Added example in `examples/cmake/add_subdir/CMakeLists.txt` that is used for documentation and regression testing.
#1248 adds the See the new Feel free to try it out and let me know if there are any issues. |
Apparently a "couple of weeks" is roughly 3 months in quarantime :-) |
@allisonvacanti Thanks for the great work! Both |
Great, glad it worked for you! It will be merged into the |
See issue NVIDIA#976. Added example in `examples/cmake/add_subdir/CMakeLists.txt` that is used for documentation and regression testing.
See issue #976. Added example in `examples/cmake/add_subdir/CMakeLists.txt` that is used for documentation and regression testing.
This has been addressed by #1248. |
I have been using the github thrust for a while before the recent merge with cuda one. I manage dependency using cmake fetchcontent. After merging with the recent update in this repo, which includes a CMakeLists.txt, I found that it breaks command like add_subdirectory() because of the following error:
Aside from having name conflicts via add_custom_target, I was expecting using thrust as a header-only library and I don't expect cmake to config building any of the test targets unless I want it so.
The text was updated successfully, but these errors were encountered: