@ -106,6 +106,13 @@
# C U D A _ C O M P U T E _ S E P A R A B L E _ C O M P I L A T I O N _ O B J E C T _ F I L E _ N A M E a n d
# C U D A _ L I N K _ S E P A R A B L E _ C O M P I L A T I O N _ O B J E C T S s h o u l d b e c a l l e d .
#
# C U D A _ S O U R C E _ P R O P E R T Y _ F O R M A T
# - - I f t h i s s o u r c e f i l e p r o p e r t y i s s e t , i t c a n o v e r r i d e t h e f o r m a t s p e c i f i e d
# t o CUDA_WRAP_SRCS ( OBJ, PTX, CUBIN, or FATBIN ) . I f a n i n p u t s o u r c e f i l e
# i s n o t a . c u f i l e , s e t t i n g t h i s f i l e w i l l c a u s e i t t o b e t r e a t e d a s a . c u
# f i l e . S e e d o c u m e n t a t i o n f o r s e t _ s o u r c e _ f i l e s _ p r o p e r t i e s o n h o w t o s e t
# t h i s p r o p e r t y .
#
# CUDA_USE_STATIC_CUDA_RUNTIME ( Default ON )
# - - W h e n e n a b l e d t h e s t a t i c v e r s i o n o f t h e C U D A r u n t i m e l i b r a r y w i l l b e u s e d
# i n C U D A _ L I B R A R I E S . I f t h e v e r s i o n o f C U D A c o n f i g u r e d d o e s n ' t s u p p o r t
@ -1294,13 +1301,19 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files)
foreach ( file ${ ARGN } )
# I g n o r e a n y f i l e m a r k e d a s a H E A D E R _ F I L E _ O N L Y
get_source_file_property ( _is_header ${ file } HEADER_FILE_ONLY )
if ( ${ file } MATCHES "\\.cu$" AND NOT _is_header )
# A l l o w p e r s o u r c e f i l e o v e r r i d e s o f t h e f o r m a t . A l s o a l l o w s c o m p i l i n g n o n - . c u f i l e s .
get_source_file_property ( _cuda_source_format ${ file } CUDA_SOURCE_PROPERTY_FORMAT )
if ( ( ${ file } MATCHES "\\.cu$" OR _cuda_source_format ) AND NOT _is_header )
# A l l o w p e r s o u r c e f i l e o v e r r i d e s o f t h e f o r m a t .
get_source_file_property ( _cuda_source_format ${ file } CUDA_SOURCE_PROPERTY_FORMAT )
if ( NOT _cuda_source_format )
set ( _cuda_source_format ${ format } )
endif ( )
# I f f i l e i s n ' t a . c u f i l e , w e n e e d t o t e l l n v c c t o t r e a t i t a s s u c h .
if ( NOT ${ file } MATCHES "\\.cu$" )
set ( cuda_language_flag -x=cu )
else ( )
set ( cuda_language_flag )
endif ( )
if ( ${ _cuda_source_format } MATCHES "OBJ" )
set ( cuda_compile_to_external_module OFF )
@ -1313,7 +1326,7 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files)
elseif ( ${ _cuda_source_format } MATCHES "FATBIN" )
set ( cuda_compile_to_external_module_type "fatbin" )
else ( )
message ( FATAL_ERROR "Invalid format flag passed to CUDA_WRAP_SRCS for file '${file}': '${_cuda_source_format}'. Use OBJ, PTX, CUBIN or FATBIN." )
message ( FATAL_ERROR "Invalid format flag passed to CUDA_WRAP_SRCS or set with CUDA_SOURCE_PROPERTY_FORMAT file property for file '${file}': '${_cuda_source_format}'. Use OBJ, PTX, CUBIN or FATBIN." )
endif ( )
endif ( )
@ -1472,10 +1485,10 @@ endmacro()
function ( _cuda_get_important_host_flags important_flags flag_string )
if ( CMAKE_GENERATOR MATCHES "Visual Studio" )
string ( REGEX MATCHALL "/M[DT][d]?" flags ${ flag_string } )
string ( REGEX MATCHALL "/M[DT][d]?" flags "${flag_string}" )
list ( APPEND ${ important_flags } ${ flags } )
else ( )
string ( REGEX MATCHALL "-fPIC" flags ${ flag_string } )
string ( REGEX MATCHALL "-fPIC" flags "${flag_string}" )
list ( APPEND ${ important_flags } ${ flags } )
endif ( )
set ( ${ important_flags } ${ ${important_flags } } PARENT_SCOPE )
@ -1535,14 +1548,14 @@ function(CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS output_file cuda_target options
list ( APPEND config_specific_flags $< $<CONFIG:${config} > : ${ f } > )
endforeach ( )
set ( important_host_flags )
_cuda_get_important_host_flags ( important_host_flags ${ CMAKE_${CUDA_C_OR_CXX } _FLAGS_ ${ config_upper } } )
_cuda_get_important_host_flags ( important_host_flags "${CMAKE_${CUDA_C_OR_CXX}_FLAGS_${config_upper}}" )
foreach ( f ${ important_host_flags } )
list ( APPEND flags $< $<CONFIG:${config} > :-Xcompiler> $< $<CONFIG:${config} > : ${ f } > )
endforeach ( )
endforeach ( )
# A d d C M A K E _ $ { C U D A _ C _ O R _ C X X } _ F L A G S
set ( important_host_flags )
_cuda_get_important_host_flags ( important_host_flags ${ CMAKE_${CUDA_C_OR_CXX } _FLAGS} )
_cuda_get_important_host_flags ( important_host_flags "${CMAKE_${CUDA_C_OR_CXX}_FLAGS}" )
foreach ( f ${ important_host_flags } )
list ( APPEND flags -Xcompiler ${ f } )
endforeach ( )