mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #2366 from blattms/makes-mixing-incompatible-gcc-nvcc-fail
Make mixing incompatible host compiler/device compiler versions fail.
This commit is contained in:
commit
42b290133a
@ -18,12 +18,37 @@ project(opm-simulators C CXX)
|
||||
cmake_minimum_required (VERSION 2.8)
|
||||
|
||||
|
||||
find_package(CUDA)
|
||||
# Make sure we are using the same compiler underneath
|
||||
# NVCC as for the rest. In the case that NVCC does not support
|
||||
# that compiler it will error out. Unfortunately this will only
|
||||
# work CMake >= 3.8. We found no way to make FindCUDA.cmake error
|
||||
# out. It seems to ignore CMAKE_NVCC_FLAGS and CMAKE. Additionally
|
||||
# our way of specifying cuda source files never worked for CMake
|
||||
# version < 3.8. Hence we deactivate cuda for these versions.
|
||||
if(NOT CMAKE_DISABLE_FIND_PACKAGE_CUDA AND
|
||||
CMAKE_VERSION VERSION_GREATER_EQUAL 3.8)
|
||||
if(NOT DEFINED ENV{CUDAHOSTCXX} AND
|
||||
(NOT CMAKE_CUDA_FLAGS OR NOT CMAKE_CUDA_FLAGS MATCHES ".*-ccbin .*"))
|
||||
set(CMAKE_CUDA_FLAGS "-ccbin ${CMAKE_CXX_COMPILER} ${CMAKE_CUDA_FLAGS}")
|
||||
endif()
|
||||
include(CheckLanguage)
|
||||
# Unfortunately check_language(CUDA) will only check whether there is
|
||||
# a nvcc compiler. It will not check whether compilation with the above
|
||||
# option works. Since the OPTIONAL flag of enable_language is currently
|
||||
# ignored CMake will error out below if the options do not work.
|
||||
check_language(CUDA)
|
||||
if(CMAKE_CUDA_COMPILER)
|
||||
enable_language(CUDA OPTIONAL)
|
||||
endif()
|
||||
# While the documentation says that it is deprecated, FindCUDA seems the
|
||||
# only easy way to determine the cublas and cusparse libraries.
|
||||
# Hence we call it unconditionally
|
||||
find_package(CUDA)
|
||||
endif()
|
||||
|
||||
if(CUDA_FOUND)
|
||||
include_directories(${CUDA_INCLUDE_DIRS})
|
||||
enable_language(CUDA)
|
||||
set(HAVE_CUDA 1)
|
||||
include_directories(${CUDA_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
option(SIBLING_SEARCH "Search for other modules in sibling directories?" ON)
|
||||
@ -320,7 +345,7 @@ endif()
|
||||
|
||||
# must link libraries after target 'flow' has been defined
|
||||
if(CUDA_FOUND)
|
||||
target_link_libraries( opmsimulators ${CUDA_cublas_LIBRARY} )
|
||||
target_link_libraries( opmsimulators ${CUDA_cusparse_LIBRARY} )
|
||||
target_link_libraries( opmsimulators PUBLIC ${CUDA_cusparse_LIBRARY} )
|
||||
target_link_libraries( opmsimulators PUBLIC ${CUDA_cublas_LIBRARY} )
|
||||
endif()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user