mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-25 14:45:12 +00:00
Fix cmake scripts so projects using CUDA .cu files build correctly. (#1441)
This commit is contained in:
parent
c8e9f3ccad
commit
9343e68b46
@ -156,6 +156,7 @@ function(pybind11_add_module target_name)
|
|||||||
# namespace; also turning it on for a pybind module compilation here avoids
|
# namespace; also turning it on for a pybind module compilation here avoids
|
||||||
# potential warnings or issues from having mixed hidden/non-hidden types.
|
# potential warnings or issues from having mixed hidden/non-hidden types.
|
||||||
set_target_properties(${target_name} PROPERTIES CXX_VISIBILITY_PRESET "hidden")
|
set_target_properties(${target_name} PROPERTIES CXX_VISIBILITY_PRESET "hidden")
|
||||||
|
set_target_properties(${target_name} PROPERTIES CUDA_VISIBILITY_PRESET "hidden")
|
||||||
|
|
||||||
if(WIN32 OR CYGWIN)
|
if(WIN32 OR CYGWIN)
|
||||||
# Link against the Python shared library on Windows
|
# Link against the Python shared library on Windows
|
||||||
@ -208,6 +209,15 @@ function(pybind11_add_module target_name)
|
|||||||
if(MSVC)
|
if(MSVC)
|
||||||
# /MP enables multithreaded builds (relevant when there are many files), /bigobj is
|
# /MP enables multithreaded builds (relevant when there are many files), /bigobj is
|
||||||
# needed for bigger binding projects due to the limit to 64k addressable sections
|
# needed for bigger binding projects due to the limit to 64k addressable sections
|
||||||
target_compile_options(${target_name} PRIVATE /MP /bigobj)
|
set(msvc_extra_options /MP /bigobj)
|
||||||
|
if(CMAKE_VERSION VERSION_LESS 3.11)
|
||||||
|
target_compile_options(${target_name} PRIVATE ${msvc_extra_options})
|
||||||
|
else()
|
||||||
|
# Only set these options for C++ files. This is important so that, for
|
||||||
|
# instance, projects that include other types of source files like CUDA
|
||||||
|
# .cu files don't get these options propagated to nvcc since that would
|
||||||
|
# cause the build to fail.
|
||||||
|
target_compile_options(${target_name} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${msvc_extra_options}>)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
Loading…
Reference in New Issue
Block a user