Skip to content

Commit

Permalink
from static lib to object lib: still fails
Browse files Browse the repository at this point in the history
  • Loading branch information
jngrad committed Apr 4, 2020
1 parent 71937be commit bc89a3e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ target_compile_options(
)

set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -fPIC -Wall -Wextra -Wno-sign-compare -Wno-unused-function -Wno-unused-variable -Wno-unused-parameter -Wno-missing-braces"
"${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-sign-compare -Wno-unused-function -Wno-unused-variable -Wno-unused-parameter -Wno-missing-braces"
)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_SYSTEM_PROCESSOR MATCHES
"arm")
Expand Down
13 changes: 9 additions & 4 deletions cmake/FindCUDACompilerClang.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,15 @@ find_library(
/usr/local/nvidia/lib NO_DEFAULT_PATH)

function(add_gpu_library)
set(options STATIC SHARED MODULE EXCLUDE_FROM_ALL)
set(options STATIC SHARED MODULE EXCLUDE_FROM_ALL OBJECT)
set(oneValueArgs)
set(multiValueArgs)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
list(REMOVE_AT ARG_UNPARSED_ARGUMENTS 0)
set_source_files_properties(${ARG_UNPARSED_ARGUMENTS} PROPERTIES LANGUAGE "CXX")
add_library(${ARGV})
set_target_properties(${ARGV0} PROPERTIES LINKER_LANGUAGE "CXX")
target_link_libraries(${ARGV0} PRIVATE ${CUDA_LIBRARY} ${CUDART_LIBRARY})
target_link_libraries(${ARGV0} PRIVATE ${CUFFT_LIBRARY})
set(LIBRARY_GPU ${ARGV0})
set_target_properties(${LIBRARY_GPU} PROPERTIES LINKER_LANGUAGE "CXX")

set_source_files_properties(${ARG_UNPARSED_ARGUMENTS} PROPERTIES COMPILE_FLAGS "${CUDA_NVCC_FLAGS} ${CUDA_NVCC_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}")
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 3.8.9)
Expand All @@ -86,6 +85,12 @@ function(add_gpu_library)
endif()
endfunction()

function(target_link_gpu_libraries)
set(LIBRARY_CPU ${ARGV0})
target_link_libraries(${LIBRARY_CPU} PRIVATE ${CUDA_LIBRARY} ${CUDART_LIBRARY})
target_link_libraries(${LIBRARY_CPU} PRIVATE ${CUFFT_LIBRARY})
endfunction()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
CudaCompilerClang REQUIRED_VARS CMAKE_CUDA_COMPILER VERSION_VAR
Expand Down
12 changes: 7 additions & 5 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,13 @@ if(CUDA)
grid_based_algorithms/fd-electrostatics_cuda.cu
virtual_sites/lb_inertialess_tracers_cuda.cu)

add_gpu_library(EspressoCuda STATIC ${EspressoCuda_SRC})
add_gpu_library(EspressoCuda OBJECT ${EspressoCuda_SRC})
add_library(EspressoCore SHARED ${EspressoCore_SRC} $<TARGET_OBJECTS:EspressoCuda>)
target_link_gpu_libraries(EspressoCore)
else()
add_library(EspressoCore SHARED ${EspressoCore_SRC})
endif(CUDA)

add_library(EspressoCore SHARED ${EspressoCore_SRC})

install(TARGETS EspressoCore LIBRARY DESTINATION ${PYTHON_INSTDIR}/espressomd)

target_link_libraries(
Expand All @@ -95,9 +97,9 @@ target_compile_definitions(EspressoCore
PUBLIC "$<$<BOOL:${H5MD}>:H5XX_USE_MPI>")

if(CUDA)
target_link_libraries(EspressoCuda PRIVATE EspressoConfig shapes utils)
#target_link_libraries(EspressoCuda PRIVATE EspressoConfig shapes utils)
target_include_directories(EspressoCuda PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(EspressoCore PRIVATE EspressoCuda)
# target_link_libraries(EspressoCore PRIVATE EspressoCudaTT)
endif(CUDA)

add_subdirectory(accumulators)
Expand Down

0 comments on commit bc89a3e

Please sign in to comment.