Skip to content

Commit

Permalink
cleanup of cuda-specific cmake options
Browse files Browse the repository at this point in the history
  • Loading branch information
gralkapk committed Jul 9, 2024
1 parent 97b93be commit bbc9400
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) 2020, MegaMol Dev Team
# All rights reserved.
#
cmake_minimum_required(VERSION 3.19...3.29 FATAL_ERROR)
cmake_minimum_required(VERSION 3.24...3.29 FATAL_ERROR)

# Vcpkg setup
set(MEGAMOL_VCPKG_VERSION "2024.06.15") # Update default-registry baseline in vcpkg-configuration.json when changing!
Expand Down
4 changes: 3 additions & 1 deletion cmake/megamol_config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,10 @@ endif ()

# CUDA
if (MEGAMOL_USE_CUDA)
if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
set(CMAKE_CUDA_ARCHITECTURES native)
endif()
enable_language(CUDA)
set(CMAKE_CUDA_ARCHITECTURES FALSE)
endif ()

# MPI
Expand Down
4 changes: 2 additions & 2 deletions plugins/molecularmaps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ if (molecularmaps_PLUGIN_ENABLED)
message(FATAL_ERROR "Molecularmaps currently only supports CUDA Version 11 or above. The version found was CUDA ${CUDA_VERSION_MAJOR} (${CMAKE_CUDA_COMPILER_VERSION}). Please turn off the Molecularmaps plugin or install a correct version of CUDA." )
endif()

set(CMAKE_CUDA_ARCHITECTURES 52)
set(CMAKE_CUDA_FLAGS_RELEASE "${CMAKE_CUDA_FLAGS} -O3")
set_target_properties(molecularmaps PROPERTIES CUDA_ARCHITECTURES 52)
target_compile_options(molecularmaps PRIVATE $<$<AND:$<COMPILE_LANGUAGE:CUDA>,$<CONFIG:RELEASE>>:-O3>)

file(GLOB_RECURSE cuda_source_files RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "src/*.cu")
file(GLOB_RECURSE cuda_header_files RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "src/*.cuh")
Expand Down
6 changes: 3 additions & 3 deletions plugins/protein_cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ if (protein_cuda_PLUGIN_ENABLED)
message(FATAL_ERROR "Protein CUDA currently only supports CUDA Version 11 or above. The version found was CUDA ${CMAKE_CUDA_COMPILER_VERSION}. Please turn off the Protein CUDA plugin or install a correct version of CUDA.")
endif ()

set(CMAKE_CUDA_ARCHITECTURES 52)
set(CMAKE_CUDA_FLAGS_RELEASE "${CMAKE_CUDA_FLAGS} -O3")
set_target_properties(protein_cuda PROPERTIES CUDA_ARCHITECTURES 52)
target_compile_options(protein_cuda PRIVATE $<$<AND:$<COMPILE_LANGUAGE:CUDA>,$<CONFIG:RELEASE>>:-O3>)

get_filename_component(CUDA_COMPILER_DIRECTORY "${CMAKE_CUDA_COMPILER}" DIRECTORY)
get_filename_component(CUDA_BIN_DIR ${CMAKE_CUDA_COMPILER} DIRECTORY)

# Suppress CUDA warnings
if (SUPPRESS_CUDA_WARNINGS)
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler \"-w\"")
target_compile_options(protein_cuda PRIVATE $<$<AND:$<COMPILE_LANGUAGE:CUDA>,$<CONFIG:DEBUG>>:-Xcompiler -w>)
endif ()

# Collect source files
Expand Down

0 comments on commit bbc9400

Please sign in to comment.