Skip to content

Commit

Permalink
Enable CUDA support in cmake when available
Browse files Browse the repository at this point in the history
Signed-off-by: Robert Young <rwy0717@gmail.com>
  • Loading branch information
rwy7 committed Jun 10, 2019
1 parent daa8b14 commit 8b36e36
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
17 changes: 17 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,23 @@ set(OMR_INSTALL_ARCHIVE_DIR ${CMAKE_INSTALL_LIBDIR} CACHE PATH "Installation dir
set(OMR_INSTALL_INC_DIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE PATH "Installation directory for headers")
set(OMR_INSTALL_DATA_DIR ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME} CACHE PATH "Installation directory for data files")

###
### CUDA Support
###

if (OMR_ENV_DATA64)
find_package(Threads)
if(Threads_FOUND)
# Threads mush be found before we can look for CUDA.
# FindCuda will error out if Threads is missing, even though CUDA itself is optional.
find_package(CUDA)
else()
set(CUDA_FOUND OFF CACHE BOOL "CUDA is disabled (threads not found)")
endif()
else()
set(CUDA_FOUND OFF CACHE BOOL "CUDA is disabled")
endif()

###
### Versions and stuff
###
Expand Down
3 changes: 1 addition & 2 deletions cmake/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ set(OMR_NOTIFY_POLICY_CONTROL OFF CACHE BOOL "TODO: Document")

set(OMR_ENV_GCC OFF CACHE BOOL "TODO: Document")


set(OMR_OPT_CUDA OFF CACHE BOOL "TODO: Document")
set(OMR_OPT_CUDA ${CUDA_FOUND} CACHE BOOL "Enable CUDA support in OMR")

set(OMR_SANITIZE OFF CACHE STRING "Sanitizer selection. Only has an effect on GNU or Clang")
7 changes: 7 additions & 0 deletions port/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ target_include_directories(omrport_obj
$<TARGET_PROPERTY:omr_base,INTERFACE_INCLUDE_DIRECTORIES>
)

if (OMR_OPT_CUDA)
target_include_directories(omrport_obj
PRIVATE
${CUDA_INCLUDE_DIRS}
)
endif()

target_compile_definitions(omrport_obj
PUBLIC
$<TARGET_PROPERTY:omr_base,INTERFACE_COMPILE_DEFINITIONS>
Expand Down

0 comments on commit 8b36e36

Please sign in to comment.