@@ -110,6 +110,24 @@ include(ipc_toolkit_use_colors)
110110# Generate position-independent code by default
111111set (CMAKE_POSITION_INDEPENDENT_CODE ON )
112112
113+ ################################################################################
114+ # CUDA
115+ ################################################################################
116+
117+ if (IPC_TOOLKIT_WITH_CUDA)
118+ # If CMAKE_CUDA_ARCHITECTURES was not specified, set it to native.
119+ if (DEFINED CMAKE_CUDA_ARCHITECTURES)
120+ message (STATUS "CMAKE_CUDA_ARCHITECTURES was specified, skipping auto-detection" )
121+ else ()
122+ message (STATUS "CMAKE_CUDA_ARCHITECTURES was not specified, set it to native" )
123+ set (CMAKE_CUDA_ARCHITECTURES "native" )
124+ endif ()
125+ message (STATUS "Targeting CUDA_ARCHITECTURES \" ${CMAKE_CUDA_ARCHITECTURES} \" " )
126+
127+ # Enable CUDA support
128+ enable_language (CUDA)
129+ endif ()
130+
113131################################################################################
114132# IPC Toolkit Library
115133################################################################################
@@ -118,6 +136,13 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
118136add_library (ipc_toolkit)
119137add_library (ipc::toolkit ALIAS ipc_toolkit)
120138
139+ if (IPC_TOOLKIT_WITH_CUDA)
140+ # We need to explicitly state that we need all CUDA files in the particle
141+ # library to be built with -dc as the member functions could be called by
142+ # other libraries and executables.
143+ set_target_properties (ipc_toolkit PROPERTIES CUDA_SEPARABLE_COMPILATION ON )
144+ endif ()
145+
121146# Fill in configuration options
122147configure_file (
123148 "${IPC_TOOLKIT_SOURCE_DIR} /config.hpp.in"
@@ -233,29 +258,6 @@ endif()
233258# Use C++17
234259target_compile_features (ipc_toolkit PUBLIC cxx_std_17)
235260
236- ################################################################################
237- # CUDA
238- ################################################################################
239-
240- if (IPC_TOOLKIT_WITH_CUDA)
241- # If CMAKE_CUDA_ARCHITECTURES was not specified, set it to native.
242- if (DEFINED CMAKE_CUDA_ARCHITECTURES)
243- message (STATUS "CMAKE_CUDA_ARCHITECTURES was specified, skipping auto-detection" )
244- else ()
245- message (STATUS "CMAKE_CUDA_ARCHITECTURES was not specified, set it to native" )
246- set (CMAKE_CUDA_ARCHITECTURES "native" )
247- endif ()
248- message (STATUS "Targeting CUDA_ARCHITECTURES \" ${CMAKE_CUDA_ARCHITECTURES} \" " )
249-
250- # Enable CUDA support
251- enable_language (CUDA)
252-
253- # We need to explicitly state that we need all CUDA files in the particle
254- # library to be built with -dc as the member functions could be called by
255- # other libraries and executables.
256- set_target_properties (ipc_toolkit PROPERTIES CUDA_SEPARABLE_COMPILATION ON )
257- endif ()
258-
259261################################################################################
260262# Tests
261263################################################################################
0 commit comments