Skip to content

Commit

Permalink
sixtracklib/cuda: attempts to fix linking issue with CMake > 3.14.x
Browse files Browse the repository at this point in the history
Backported from #PR130

- The flag CUDA_RESOLVE_DEVICE_SYMBOLS should be enabled by default on
  shared libraries like SixTrackLib. The property does not work on
  OBJECT libraries like sixtrack_cuda_device. It seems that starting
  with cmake 3.15, cmake did not pick up the property for the resulting
  compound SHARED library just by inferring the dependency on the CUDA
  device part.

  This fix attempts to rectify this by adding the property explicitly
  to the SHARED sixtracklib library if the sixtrack_cuda_device
  target is present.

  Tested on CMake 3.14, 3.16 und 3.18 -> seems to work

- Note: this would fix issue SixTrack#109 but more investigation is required whether
  this solves all problems encountered therein
  • Loading branch information
martinschwinzerl committed Oct 22, 2020
1 parent 1da3765 commit 762615c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 4 additions & 0 deletions sixtracklib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ set_target_properties( sixtrack PROPERTIES
LINKER_LANGUAGE C POSITION_INDEPENDENT_CODE ON C_STANDARD 99
DEBUG_POSTFIX d C_STANDARD_REQUIRED ON )

if( TARGET sixtrack_cuda_device )
set_target_properties( sixtrack PROPERTIES CUDA_RESOLVE_DEVICE_SYMBOLS ON )
endif()

target_compile_options( sixtrack PRIVATE
${SIXTRACKLIB_C99_FLAGS} ${SIXTRACKLIB_CPU_FLAGS}
${SIXTRACKL_C99_AUTOVEC_FLAGS} )
Expand Down
12 changes: 4 additions & 8 deletions sixtracklib/cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,10 @@ add_library( sixtrack_cuda_device OBJECT
target_compile_definitions( sixtrack_cuda_device
PUBLIC ${SIXTRACKL_CUDA_DEVICE_DEFINITIONS} )

set_target_properties( sixtrack_cuda_device PROPERTIES POSITION_INDEPENDENT_CODE ON )
set_target_properties( sixtrack_cuda_device PROPERTIES LINKER_LANGUAGE C )
set_target_properties( sixtrack_cuda_device PROPERTIES CXX_STANDARD 11 )
set_target_properties( sixtrack_cuda_device PROPERTIES CXX_STANDARD_REQUIRED ON )
set_target_properties( sixtrack_cuda_device PROPERTIES CUDA_SEPARABLE_COMPILATION ON )
set_target_properties( sixtrack_cuda_device PROPERTIES CUDA_RESOLVE_DEVICE_SYMBOLS OFF )
set_target_properties( sixtrack_cuda_device PROPERTIES CUDA_STANDARD 11 )
set_target_properties( sixtrack_cuda_device PROPERTIES CUDA_STANDARD_REQUIRED 11 )
set_target_properties( sixtrack_cuda_device PROPERTIES
POSITION_INDEPENDENT_CODE ON LINKER_LANGUAGE C CXX_STANDARD 11
CXX_STANDARD_REQUIRED ON CUDA_SEPARABLE_COMPILATION ON
CUDA_RESOLVE_DEVICE_SYMBOLS ON CUDA_STANDARD 11 CUDA_STANDARD_REQUIRED 11 )

target_include_directories( sixtrack_cuda_device PRIVATE ${CMAKE_SOURCE_DIR} )

Expand Down

0 comments on commit 762615c

Please sign in to comment.