Skip to content

Commit 2f1644a

Browse files
authored
POSITION_INDEPENDENT_CODE ON
1 parent 1d6e08e commit 2f1644a

File tree

1 file changed

+10
-25
lines changed

1 file changed

+10
-25
lines changed

CMakeLists.txt

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,13 @@ if(SCALABLE_CCD_WITH_CUDA)
165165
message(FATAL_ERROR "No CUDA support found!")
166166
endif()
167167

168-
# Enable separable compilation for CUDA
169-
set_target_properties(scalable_ccd PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
170-
171168
# We need to explicitly state that we need all CUDA files in the particle
172169
# Enable separable compilation for CUDA
173170
# library to be built with -dc as the member functions could be called by
174171
# other libraries and executables.
172+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
173+
set_target_properties(scalable_ccd PROPERTIES CUDA_SEPARABLE_COMPILATION ON POSITION_INDEPENDENT_CODE ON)
174+
175175
if(DEFINED SCALABLE_CCD_CUDA_ARCHITECTURES)
176176
message(STATUS "CUDA_ARCHITECTURES was specified, skipping auto-detection")
177177
set(CMAKE_CUDA_ARCHITECTURES ${SCALABLE_CCD_CUDA_ARCHITECTURES})
@@ -191,34 +191,19 @@ if(SCALABLE_CCD_WITH_CUDA)
191191

192192
if(APPLE)
193193
# We need to add the path to the driver (libcuda.dylib) as an rpath,
194-
# Add rpath for CUDA on macOS
195194
# so that the static cuda runtime can find it at runtime.
196195
set_property(TARGET scalable_ccd
197196
PROPERTY
198197
BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
199198
endif()
200199

201-
# Conditionally add CUDA compile options based on the platform
202-
if(WIN32)
203-
target_compile_options(scalable_ccd PRIVATE
204-
$<$<COMPILE_LANGUAGE:CUDA>:
205-
--generate-line-info
206-
--use_fast_math
207-
--relocatable-device-code=true
208-
>
209-
)
210-
else()
211-
target_compile_options(scalable_ccd PRIVATE
212-
$<$<COMPILE_LANGUAGE:CUDA>:
213-
--generate-line-info
214-
--use_fast_math
215-
--relocatable-device-code=true
216-
# --ptxas-options=-v
217-
# --maxrregcount=7
218-
-fPIC # https://stackoverflow.com/questions/5311515/gcc-fpic-option
219-
>
220-
)
221-
endif()
200+
target_compile_options(scalable_ccd PRIVATE
201+
$<$<COMPILE_LANGUAGE:CUDA>:
202+
--generate-line-info
203+
--use_fast_math
204+
--relocatable-device-code=true
205+
>
206+
)
222207

223208
find_package(CUDAToolkit)
224209
target_link_libraries(scalable_ccd PUBLIC CUDA::cudart)

0 commit comments

Comments
 (0)