123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305 |
- cmake_policy(PUSH)
- cmake_policy(SET CMP0007 NEW)
- if(NOT generated_file)
- message(FATAL_ERROR "You must specify generated_file on the command line")
- endif()
- set(CMAKE_COMMAND "@CMAKE_COMMAND@")
- set(source_file "@source_file@")
- set(NVCC_generated_dependency_file "@NVCC_generated_dependency_file@")
- set(cmake_dependency_file "@cmake_dependency_file@")
- set(CUDA_make2cmake "@CUDA_make2cmake@")
- set(CUDA_parse_cubin "@CUDA_parse_cubin@")
- set(build_cubin @build_cubin@)
- set(CUDA_HOST_COMPILER "@CUDA_HOST_COMPILER@")
- set(generated_file_path "@generated_file_path@")
- set(generated_file_internal "@generated_file@")
- set(generated_cubin_file_internal "@generated_cubin_file@")
- set(CUDA_NVCC_EXECUTABLE "@CUDA_NVCC_EXECUTABLE@")
- set(CUDA_NVCC_FLAGS @CUDA_NVCC_FLAGS@ ;; @CUDA_WRAP_OPTION_NVCC_FLAGS@)
- @CUDA_NVCC_FLAGS_CONFIG@
- set(nvcc_flags @nvcc_flags@)
- set(CUDA_NVCC_INCLUDE_DIRS "@CUDA_NVCC_INCLUDE_DIRS@")
- set(CUDA_NVCC_COMPILE_DEFINITIONS [==[@CUDA_NVCC_COMPILE_DEFINITIONS@]==])
- set(format_flag "@format_flag@")
- set(cuda_language_flag @cuda_language_flag@)
- list(REMOVE_DUPLICATES CUDA_NVCC_INCLUDE_DIRS)
- set(CUDA_NVCC_INCLUDE_ARGS)
- foreach(dir ${CUDA_NVCC_INCLUDE_DIRS})
-
- list(APPEND CUDA_NVCC_INCLUDE_ARGS "-I${dir}")
- endforeach()
- list(REMOVE_DUPLICATES CUDA_NVCC_COMPILE_DEFINITIONS)
- foreach(def ${CUDA_NVCC_COMPILE_DEFINITIONS})
- list(APPEND nvcc_flags "-D${def}")
- endforeach()
- if(build_cubin AND NOT generated_cubin_file)
- message(FATAL_ERROR "You must specify generated_cubin_file on the command line")
- endif()
- @CUDA_HOST_FLAGS@
- set(nvcc_host_compiler_flags "")
- if(NOT build_configuration)
- set(build_configuration Debug)
- endif()
- string(TOUPPER "${build_configuration}" build_configuration)
- foreach(flag ${CMAKE_HOST_FLAGS} ${CMAKE_HOST_FLAGS_${build_configuration}})
-
- string(APPEND nvcc_host_compiler_flags ",\"${flag}\"")
- endforeach()
- if (nvcc_host_compiler_flags)
- set(nvcc_host_compiler_flags "-Xcompiler" ${nvcc_host_compiler_flags})
- endif()
- list(APPEND CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS_${build_configuration}})
- list( FIND CUDA_NVCC_FLAGS "-ccbin" ccbin_found0 )
- list( FIND CUDA_NVCC_FLAGS "--compiler-bindir" ccbin_found1 )
- if( ccbin_found0 LESS 0 AND ccbin_found1 LESS 0 AND CUDA_HOST_COMPILER )
- if (CUDA_HOST_COMPILER STREQUAL "@_CUDA_MSVC_HOST_COMPILER@" AND DEFINED CCBIN)
- set(CCBIN -ccbin "${CCBIN}")
- else()
- set(CCBIN -ccbin "${CUDA_HOST_COMPILER}")
- endif()
- endif()
- macro(cuda_execute_process status command)
- set(_command ${command})
- if(NOT "x${_command}" STREQUAL "xCOMMAND")
- message(FATAL_ERROR "Malformed call to cuda_execute_process. Missing COMMAND as second argument. (command = ${command})")
- endif()
- if(verbose)
- execute_process(COMMAND "${CMAKE_COMMAND}" -E echo -- ${status})
-
-
-
- set(cuda_execute_process_string)
- foreach(arg ${ARGN})
-
- string(REPLACE "\"" "\\\"" arg ${arg})
-
- if(arg MATCHES " ")
- list(APPEND cuda_execute_process_string "\"${arg}\"")
- else()
- list(APPEND cuda_execute_process_string ${arg})
- endif()
- endforeach()
-
- execute_process(COMMAND ${CMAKE_COMMAND} -E echo ${cuda_execute_process_string})
- endif()
-
- execute_process(COMMAND ${ARGN} RESULT_VARIABLE CUDA_result )
- endmacro()
- cuda_execute_process(
- "Removing ${generated_file}"
- COMMAND "${CMAKE_COMMAND}" -E remove "${generated_file}"
- )
- set(depends_CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS}")
- set(CUDA_VERSION @CUDA_VERSION@)
- if(CUDA_VERSION VERSION_LESS "3.0")
-
- list(REMOVE_ITEM depends_CUDA_NVCC_FLAGS "-G")
- endif()
- set(CUDACC_DEFINE -D__CUDACC__)
- cuda_execute_process(
- "Generating dependency file: ${NVCC_generated_dependency_file}"
- COMMAND "${CUDA_NVCC_EXECUTABLE}"
- -M
- ${CUDACC_DEFINE}
- "${source_file}"
- -o "${NVCC_generated_dependency_file}"
- ${CCBIN}
- ${nvcc_flags}
- ${nvcc_host_compiler_flags}
- ${depends_CUDA_NVCC_FLAGS}
- -DNVCC
- ${CUDA_NVCC_INCLUDE_ARGS}
- )
- if(CUDA_result)
- message(FATAL_ERROR "Error generating ${generated_file}")
- endif()
- cuda_execute_process(
- "Generating temporary cmake readable file: ${cmake_dependency_file}.tmp"
- COMMAND "${CMAKE_COMMAND}"
- -D "input_file:FILEPATH=${NVCC_generated_dependency_file}"
- -D "output_file:FILEPATH=${cmake_dependency_file}.tmp"
- -D "verbose=${verbose}"
- -P "${CUDA_make2cmake}"
- )
- if(CUDA_result)
- message(FATAL_ERROR "Error generating ${generated_file}")
- endif()
- cuda_execute_process(
- "Copy if different ${cmake_dependency_file}.tmp to ${cmake_dependency_file}"
- COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${cmake_dependency_file}.tmp" "${cmake_dependency_file}"
- )
- if(CUDA_result)
- message(FATAL_ERROR "Error generating ${generated_file}")
- endif()
- cuda_execute_process(
- "Removing ${cmake_dependency_file}.tmp and ${NVCC_generated_dependency_file}"
- COMMAND "${CMAKE_COMMAND}" -E remove "${cmake_dependency_file}.tmp" "${NVCC_generated_dependency_file}"
- )
- if(CUDA_result)
- message(FATAL_ERROR "Error generating ${generated_file}")
- endif()
- cuda_execute_process(
- "Generating ${generated_file}"
- COMMAND "${CUDA_NVCC_EXECUTABLE}"
- "${source_file}"
- ${cuda_language_flag}
- ${format_flag} -o "${generated_file}"
- ${CCBIN}
- ${nvcc_flags}
- ${nvcc_host_compiler_flags}
- ${CUDA_NVCC_FLAGS}
- -DNVCC
- ${CUDA_NVCC_INCLUDE_ARGS}
- )
- if(CUDA_result)
-
- cuda_execute_process(
- "Removing ${generated_file}"
- COMMAND "${CMAKE_COMMAND}" -E remove "${generated_file}"
- )
- message(FATAL_ERROR "Error generating file ${generated_file}")
- else()
- if(verbose)
- message("Generated ${generated_file} successfully.")
- endif()
- endif()
- if( build_cubin )
-
- cuda_execute_process(
- "Generating ${generated_cubin_file}"
- COMMAND "${CUDA_NVCC_EXECUTABLE}"
- "${source_file}"
- ${CUDA_NVCC_FLAGS}
- ${nvcc_flags}
- ${CCBIN}
- ${nvcc_host_compiler_flags}
- -DNVCC
- -cubin
- -o "${generated_cubin_file}"
- ${CUDA_NVCC_INCLUDE_ARGS}
- )
-
- cuda_execute_process(
- "Executing the parser script"
- COMMAND "${CMAKE_COMMAND}"
- -D "input_file:STRING=${generated_cubin_file}"
- -P "${CUDA_parse_cubin}"
- )
- endif()
- cmake_policy(POP)
|