Output build.info
This commit is contained in:
parent
046661745d
commit
b7436e41b9
|
@ -227,3 +227,15 @@ install(FILES
|
||||||
install(EXPORT ${MYNTEYE_NAME}-targets
|
install(EXPORT ${MYNTEYE_NAME}-targets
|
||||||
DESTINATION ${MYNTEYE_CMAKE_INSTALLDIR}
|
DESTINATION ${MYNTEYE_CMAKE_INSTALLDIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
find_package(CUDA QUIET)
|
||||||
|
|
||||||
|
configure_file(
|
||||||
|
cmake/templates/build.info.in
|
||||||
|
build.info @ONLY
|
||||||
|
)
|
||||||
|
|
||||||
|
install(FILES
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/build.info
|
||||||
|
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/mynteye
|
||||||
|
)
|
||||||
|
|
|
@ -21,14 +21,45 @@ set(CUR_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||||
|
|
||||||
if(MSVC OR MSYS OR MINGW)
|
if(MSVC OR MSYS OR MINGW)
|
||||||
set(OS_WIN TRUE)
|
set(OS_WIN TRUE)
|
||||||
|
set(HOST_OS Win)
|
||||||
elseif(APPLE)
|
elseif(APPLE)
|
||||||
set(OS_MAC TRUE)
|
set(OS_MAC TRUE)
|
||||||
|
set(HOST_OS Mac)
|
||||||
elseif(UNIX)
|
elseif(UNIX)
|
||||||
set(OS_LINUX TRUE)
|
set(OS_LINUX TRUE)
|
||||||
|
set(HOST_OS Linux)
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR "Unsupported OS.")
|
message(FATAL_ERROR "Unsupported OS.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(HOST_NAME "${HOST_OS}")
|
||||||
|
|
||||||
|
if(OS_LINUX)
|
||||||
|
execute_process(COMMAND uname -a COMMAND tr -d '\n' OUTPUT_VARIABLE UNAME_A)
|
||||||
|
string(TOLOWER "${UNAME_A}" UNAME_A)
|
||||||
|
if(${UNAME_A} MATCHES ".*(tegra|jetsonbot).*")
|
||||||
|
set(OS_TEGRA TRUE)
|
||||||
|
set(HOST_NAME Tegra)
|
||||||
|
elseif(${UNAME_A} MATCHES ".*ubuntu.*")
|
||||||
|
set(OS_UBUNTU TRUE)
|
||||||
|
set(HOST_NAME Ubuntu)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(${CMAKE_CURRENT_LIST_DIR}/TargetArch.cmake)
|
||||||
|
target_architecture(HOST_ARCH)
|
||||||
|
message(STATUS "HOST_ARCH: ${HOST_ARCH}")
|
||||||
|
|
||||||
|
if(CMAKE_COMPILER_IS_GNUCC)
|
||||||
|
execute_process(COMMAND gcc -dumpversion COMMAND cut -c 1-3 COMMAND tr -d '\n' OUTPUT_VARIABLE GCC_VERSION)
|
||||||
|
string(REGEX MATCHALL "[0-9]+" GCC_VERSION_COMPONMENTS ${GCC_VERSION})
|
||||||
|
list(GET GCC_VERSION_COMPONMENTS 0 GCC_VERSION_MAJOR)
|
||||||
|
list(GET GCC_VERSION_COMPONMENTS 1 GCC_VERSION_MINOR)
|
||||||
|
message(STATUS "GCC_VERSION: ${GCC_VERSION}")
|
||||||
|
#message(STATUS "GCC_VERSION_MAJOR: ${GCC_VERSION_MAJOR}")
|
||||||
|
#message(STATUS "GCC_VERSION_MINOR: ${GCC_VERSION_MINOR}")
|
||||||
|
endif()
|
||||||
|
|
||||||
# set_outdir(ARCHIVE_OUTPUT_DIRECTORY
|
# set_outdir(ARCHIVE_OUTPUT_DIRECTORY
|
||||||
# LIBRARY_OUTPUT_DIRECTORY
|
# LIBRARY_OUTPUT_DIRECTORY
|
||||||
# RUNTIME_OUTPUT_DIRECTORY)
|
# RUNTIME_OUTPUT_DIRECTORY)
|
||||||
|
|
1741
cmake/FindCUDA.cmake
Normal file
1741
cmake/FindCUDA.cmake
Normal file
File diff suppressed because it is too large
Load Diff
92
cmake/FindCUDA/make2cmake.cmake
Normal file
92
cmake/FindCUDA/make2cmake.cmake
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
# James Bigler, NVIDIA Corp (nvidia.com - jbigler)
|
||||||
|
# Abe Stephens, SCI Institute -- http://www.sci.utah.edu/~abe/FindCuda.html
|
||||||
|
#
|
||||||
|
# Copyright (c) 2008 - 2009 NVIDIA Corporation. All rights reserved.
|
||||||
|
#
|
||||||
|
# Copyright (c) 2007-2009
|
||||||
|
# Scientific Computing and Imaging Institute, University of Utah
|
||||||
|
#
|
||||||
|
# This code is licensed under the MIT License. See the FindCUDA.cmake script
|
||||||
|
# for the text of the license.
|
||||||
|
|
||||||
|
# The MIT License
|
||||||
|
#
|
||||||
|
# License for the specific language governing rights and limitations under
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
# copy of this software and associated documentation files (the "Software"),
|
||||||
|
# to deal in the Software without restriction, including without limitation
|
||||||
|
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
# and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
# Software is furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included
|
||||||
|
# in all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
# DEALINGS IN THE SOFTWARE.
|
||||||
|
#
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
# This converts a file written in makefile syntax into one that can be included
|
||||||
|
# by CMake.
|
||||||
|
|
||||||
|
file(READ ${input_file} depend_text)
|
||||||
|
|
||||||
|
if (NOT "${depend_text}" STREQUAL "")
|
||||||
|
|
||||||
|
# message("FOUND DEPENDS")
|
||||||
|
|
||||||
|
string(REPLACE "\\ " " " depend_text ${depend_text})
|
||||||
|
|
||||||
|
# This works for the nvcc -M generated dependency files.
|
||||||
|
string(REGEX REPLACE "^.* : " "" depend_text ${depend_text})
|
||||||
|
string(REGEX REPLACE "[ \\\\]*\n" ";" depend_text ${depend_text})
|
||||||
|
|
||||||
|
set(dependency_list "")
|
||||||
|
|
||||||
|
foreach(file ${depend_text})
|
||||||
|
|
||||||
|
string(REGEX REPLACE "^ +" "" file ${file})
|
||||||
|
|
||||||
|
# OK, now if we had a UNC path, nvcc has a tendency to only output the first '/'
|
||||||
|
# instead of '//'. Here we will test to see if the file exists, if it doesn't then
|
||||||
|
# try to prepend another '/' to the path and test again. If it still fails remove the
|
||||||
|
# path.
|
||||||
|
|
||||||
|
if(NOT EXISTS "${file}")
|
||||||
|
if (EXISTS "/${file}")
|
||||||
|
set(file "/${file}")
|
||||||
|
else()
|
||||||
|
message(WARNING " Removing non-existent dependency file: ${file}")
|
||||||
|
set(file "")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT IS_DIRECTORY "${file}")
|
||||||
|
# If softlinks start to matter, we should change this to REALPATH. For now we need
|
||||||
|
# to flatten paths, because nvcc can generate stuff like /bin/../include instead of
|
||||||
|
# just /include.
|
||||||
|
get_filename_component(file_absolute "${file}" ABSOLUTE)
|
||||||
|
list(APPEND dependency_list "${file_absolute}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
else()
|
||||||
|
# message("FOUND NO DEPENDS")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Remove the duplicate entries and sort them.
|
||||||
|
list(REMOVE_DUPLICATES dependency_list)
|
||||||
|
list(SORT dependency_list)
|
||||||
|
|
||||||
|
foreach(file ${dependency_list})
|
||||||
|
set(cuda_nvcc_depend "${cuda_nvcc_depend} \"${file}\"\n")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
file(WRITE ${output_file} "# Generated by: make2cmake.cmake\nSET(CUDA_NVCC_DEPEND\n ${cuda_nvcc_depend})\n\n")
|
109
cmake/FindCUDA/parse_cubin.cmake
Normal file
109
cmake/FindCUDA/parse_cubin.cmake
Normal file
|
@ -0,0 +1,109 @@
|
||||||
|
# James Bigler, NVIDIA Corp (nvidia.com - jbigler)
|
||||||
|
# Abe Stephens, SCI Institute -- http://www.sci.utah.edu/~abe/FindCuda.html
|
||||||
|
#
|
||||||
|
# Copyright (c) 2008 - 2009 NVIDIA Corporation. All rights reserved.
|
||||||
|
#
|
||||||
|
# Copyright (c) 2007-2009
|
||||||
|
# Scientific Computing and Imaging Institute, University of Utah
|
||||||
|
#
|
||||||
|
# This code is licensed under the MIT License. See the FindCUDA.cmake script
|
||||||
|
# for the text of the license.
|
||||||
|
|
||||||
|
# The MIT License
|
||||||
|
#
|
||||||
|
# License for the specific language governing rights and limitations under
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
# copy of this software and associated documentation files (the "Software"),
|
||||||
|
# to deal in the Software without restriction, including without limitation
|
||||||
|
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
# and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
# Software is furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included
|
||||||
|
# in all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
# DEALINGS IN THE SOFTWARE.
|
||||||
|
#
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
# Parses a .cubin file produced by nvcc and reports statistics about the file.
|
||||||
|
|
||||||
|
|
||||||
|
file(READ ${input_file} file_text)
|
||||||
|
|
||||||
|
if (NOT "${file_text}" STREQUAL "")
|
||||||
|
|
||||||
|
string(REPLACE ";" "\\;" file_text ${file_text})
|
||||||
|
string(REPLACE "\ncode" ";code" file_text ${file_text})
|
||||||
|
|
||||||
|
list(LENGTH file_text len)
|
||||||
|
|
||||||
|
foreach(line ${file_text})
|
||||||
|
|
||||||
|
# Only look at "code { }" blocks.
|
||||||
|
if(line MATCHES "^code")
|
||||||
|
|
||||||
|
# Break into individual lines.
|
||||||
|
string(REGEX REPLACE "\n" ";" line ${line})
|
||||||
|
|
||||||
|
foreach(entry ${line})
|
||||||
|
|
||||||
|
# Extract kernel names.
|
||||||
|
if (${entry} MATCHES "[^g]name = ([^ ]+)")
|
||||||
|
set(entry "${CMAKE_MATCH_1}")
|
||||||
|
|
||||||
|
# Check to see if the kernel name starts with "_"
|
||||||
|
set(skip FALSE)
|
||||||
|
# if (${entry} MATCHES "^_")
|
||||||
|
# Skip the rest of this block.
|
||||||
|
# message("Skipping ${entry}")
|
||||||
|
# set(skip TRUE)
|
||||||
|
# else ()
|
||||||
|
message("Kernel: ${entry}")
|
||||||
|
# endif ()
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Skip the rest of the block if necessary
|
||||||
|
if(NOT skip)
|
||||||
|
|
||||||
|
# Registers
|
||||||
|
if (${entry} MATCHES "reg([ ]+)=([ ]+)([^ ]+)")
|
||||||
|
set(entry "${CMAKE_MATCH_3}")
|
||||||
|
message("Registers: ${entry}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Local memory
|
||||||
|
if (${entry} MATCHES "lmem([ ]+)=([ ]+)([^ ]+)")
|
||||||
|
set(entry "${CMAKE_MATCH_3}")
|
||||||
|
message("Local: ${entry}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Shared memory
|
||||||
|
if (${entry} MATCHES "smem([ ]+)=([ ]+)([^ ]+)")
|
||||||
|
set(entry "${CMAKE_MATCH_3}")
|
||||||
|
message("Shared: ${entry}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (${entry} MATCHES "^}")
|
||||||
|
message("")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
else()
|
||||||
|
# message("FOUND NO DEPENDS")
|
||||||
|
endif()
|
288
cmake/FindCUDA/run_nvcc.cmake
Normal file
288
cmake/FindCUDA/run_nvcc.cmake
Normal file
|
@ -0,0 +1,288 @@
|
||||||
|
# James Bigler, NVIDIA Corp (nvidia.com - jbigler)
|
||||||
|
#
|
||||||
|
# Copyright (c) 2008 - 2009 NVIDIA Corporation. All rights reserved.
|
||||||
|
#
|
||||||
|
# This code is licensed under the MIT License. See the FindCUDA.cmake script
|
||||||
|
# for the text of the license.
|
||||||
|
|
||||||
|
# The MIT License
|
||||||
|
#
|
||||||
|
# License for the specific language governing rights and limitations under
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
# copy of this software and associated documentation files (the "Software"),
|
||||||
|
# to deal in the Software without restriction, including without limitation
|
||||||
|
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
# and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
# Software is furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included
|
||||||
|
# in all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
# DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
|
# This file runs the nvcc commands to produce the desired output file along with
|
||||||
|
# the dependency file needed by CMake to compute dependencies. In addition the
|
||||||
|
# file checks the output of each command and if the command fails it deletes the
|
||||||
|
# output files.
|
||||||
|
|
||||||
|
# Input variables
|
||||||
|
#
|
||||||
|
# verbose:BOOL=<> OFF: Be as quiet as possible (default)
|
||||||
|
# ON : Describe each step
|
||||||
|
#
|
||||||
|
# build_configuration:STRING=<> Typically one of Debug, MinSizeRel, Release, or
|
||||||
|
# RelWithDebInfo, but it should match one of the
|
||||||
|
# entries in CUDA_HOST_FLAGS. This is the build
|
||||||
|
# configuration used when compiling the code. If
|
||||||
|
# blank or unspecified Debug is assumed as this is
|
||||||
|
# what CMake does.
|
||||||
|
#
|
||||||
|
# generated_file:STRING=<> File to generate. This argument must be passed in.
|
||||||
|
#
|
||||||
|
# generated_cubin_file:STRING=<> File to generate. This argument must be passed
|
||||||
|
# in if build_cubin is true.
|
||||||
|
|
||||||
|
if(NOT generated_file)
|
||||||
|
message(FATAL_ERROR "You must specify generated_file on the command line")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Set these up as variables to make reading the generated file easier
|
||||||
|
set(CMAKE_COMMAND "@CMAKE_COMMAND@") # path
|
||||||
|
set(source_file "@source_file@") # path
|
||||||
|
set(NVCC_generated_dependency_file "@NVCC_generated_dependency_file@") # path
|
||||||
|
set(cmake_dependency_file "@cmake_dependency_file@") # path
|
||||||
|
set(CUDA_make2cmake "@CUDA_make2cmake@") # path
|
||||||
|
set(CUDA_parse_cubin "@CUDA_parse_cubin@") # path
|
||||||
|
set(build_cubin @build_cubin@) # bool
|
||||||
|
set(CUDA_HOST_COMPILER "@CUDA_HOST_COMPILER@") # path
|
||||||
|
# We won't actually use these variables for now, but we need to set this, in
|
||||||
|
# order to force this file to be run again if it changes.
|
||||||
|
set(generated_file_path "@generated_file_path@") # path
|
||||||
|
set(generated_file_internal "@generated_file@") # path
|
||||||
|
set(generated_cubin_file_internal "@generated_cubin_file@") # path
|
||||||
|
|
||||||
|
set(CUDA_NVCC_EXECUTABLE "@CUDA_NVCC_EXECUTABLE@") # path
|
||||||
|
set(CUDA_NVCC_FLAGS @CUDA_NVCC_FLAGS@ ;; @CUDA_WRAP_OPTION_NVCC_FLAGS@) # list
|
||||||
|
@CUDA_NVCC_FLAGS_CONFIG@
|
||||||
|
set(nvcc_flags "@nvcc_flags@") # list
|
||||||
|
set(CUDA_NVCC_INCLUDE_ARGS "@CUDA_NVCC_INCLUDE_ARGS@") # list (needs to be in quotes to handle spaces properly).
|
||||||
|
set(format_flag "@format_flag@") # string
|
||||||
|
|
||||||
|
if(build_cubin AND NOT generated_cubin_file)
|
||||||
|
message(FATAL_ERROR "You must specify generated_cubin_file on the command line")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# This is the list of host compilation flags. It C or CXX should already have
|
||||||
|
# been chosen by FindCUDA.cmake.
|
||||||
|
@CUDA_HOST_FLAGS@
|
||||||
|
|
||||||
|
# Take the compiler flags and package them up to be sent to the compiler via -Xcompiler
|
||||||
|
set(nvcc_host_compiler_flags "")
|
||||||
|
# If we weren't given a build_configuration, use Debug.
|
||||||
|
if(NOT build_configuration)
|
||||||
|
set(build_configuration Debug)
|
||||||
|
endif()
|
||||||
|
string(TOUPPER "${build_configuration}" build_configuration)
|
||||||
|
#message("CUDA_NVCC_HOST_COMPILER_FLAGS = ${CUDA_NVCC_HOST_COMPILER_FLAGS}")
|
||||||
|
foreach(flag ${CMAKE_HOST_FLAGS} ${CMAKE_HOST_FLAGS_${build_configuration}})
|
||||||
|
# Extra quotes are added around each flag to help nvcc parse out flags with spaces.
|
||||||
|
set(nvcc_host_compiler_flags "${nvcc_host_compiler_flags},\"${flag}\"")
|
||||||
|
endforeach()
|
||||||
|
if (nvcc_host_compiler_flags)
|
||||||
|
set(nvcc_host_compiler_flags "-Xcompiler" ${nvcc_host_compiler_flags})
|
||||||
|
endif()
|
||||||
|
#message("nvcc_host_compiler_flags = \"${nvcc_host_compiler_flags}\"")
|
||||||
|
# Add the build specific configuration flags
|
||||||
|
list(APPEND CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS_${build_configuration}})
|
||||||
|
|
||||||
|
# Any -ccbin existing in CUDA_NVCC_FLAGS gets highest priority
|
||||||
|
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()
|
||||||
|
|
||||||
|
# cuda_execute_process - Executes a command with optional command echo and status message.
|
||||||
|
#
|
||||||
|
# status - Status message to print if verbose is true
|
||||||
|
# command - COMMAND argument from the usual execute_process argument structure
|
||||||
|
# ARGN - Remaining arguments are the command with arguments
|
||||||
|
#
|
||||||
|
# CUDA_result - return value from running the command
|
||||||
|
#
|
||||||
|
# Make this a macro instead of a function, so that things like RESULT_VARIABLE
|
||||||
|
# and other return variables are present after executing the process.
|
||||||
|
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})
|
||||||
|
# Now we need to build up our command string. We are accounting for quotes
|
||||||
|
# and spaces, anything else is left up to the user to fix if they want to
|
||||||
|
# copy and paste a runnable command line.
|
||||||
|
set(cuda_execute_process_string)
|
||||||
|
foreach(arg ${ARGN})
|
||||||
|
# If there are quotes, excape them, so they come through.
|
||||||
|
string(REPLACE "\"" "\\\"" arg ${arg})
|
||||||
|
# Args with spaces need quotes around them to get them to be parsed as a single argument.
|
||||||
|
if(arg MATCHES " ")
|
||||||
|
list(APPEND cuda_execute_process_string "\"${arg}\"")
|
||||||
|
else()
|
||||||
|
list(APPEND cuda_execute_process_string ${arg})
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
# Echo the command
|
||||||
|
execute_process(COMMAND ${CMAKE_COMMAND} -E echo ${cuda_execute_process_string})
|
||||||
|
endif()
|
||||||
|
# Run the command
|
||||||
|
execute_process(COMMAND ${ARGN} RESULT_VARIABLE CUDA_result )
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
# Delete the target file
|
||||||
|
cuda_execute_process(
|
||||||
|
"Removing ${generated_file}"
|
||||||
|
COMMAND "${CMAKE_COMMAND}" -E remove "${generated_file}"
|
||||||
|
)
|
||||||
|
|
||||||
|
# For CUDA 2.3 and below, -G -M doesn't work, so remove the -G flag
|
||||||
|
# for dependency generation and hope for the best.
|
||||||
|
set(depends_CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS}")
|
||||||
|
set(CUDA_VERSION @CUDA_VERSION@)
|
||||||
|
if(CUDA_VERSION VERSION_LESS "3.0")
|
||||||
|
cmake_policy(PUSH)
|
||||||
|
# CMake policy 0007 NEW states that empty list elements are not
|
||||||
|
# ignored. I'm just setting it to avoid the warning that's printed.
|
||||||
|
cmake_policy(SET CMP0007 NEW)
|
||||||
|
# Note that this will remove all occurrences of -G.
|
||||||
|
list(REMOVE_ITEM depends_CUDA_NVCC_FLAGS "-G")
|
||||||
|
cmake_policy(POP)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# nvcc doesn't define __CUDACC__ for some reason when generating dependency files. This
|
||||||
|
# can cause incorrect dependencies when #including files based on this macro which is
|
||||||
|
# defined in the generating passes of nvcc invocation. We will go ahead and manually
|
||||||
|
# define this for now until a future version fixes this bug.
|
||||||
|
set(CUDACC_DEFINE -D__CUDACC__)
|
||||||
|
|
||||||
|
# Generate the dependency file
|
||||||
|
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()
|
||||||
|
|
||||||
|
# Generate the cmake readable dependency file to a temp file. Don't put the
|
||||||
|
# quotes just around the filenames for the input_file and output_file variables.
|
||||||
|
# CMake will pass the quotes through and not be able to find the file.
|
||||||
|
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"
|
||||||
|
-P "${CUDA_make2cmake}"
|
||||||
|
)
|
||||||
|
|
||||||
|
if(CUDA_result)
|
||||||
|
message(FATAL_ERROR "Error generating ${generated_file}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Copy the file if it is different
|
||||||
|
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()
|
||||||
|
|
||||||
|
# Delete the temporary file
|
||||||
|
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()
|
||||||
|
|
||||||
|
# Generate the code
|
||||||
|
cuda_execute_process(
|
||||||
|
"Generating ${generated_file}"
|
||||||
|
COMMAND "${CUDA_NVCC_EXECUTABLE}"
|
||||||
|
"${source_file}"
|
||||||
|
${format_flag} -o "${generated_file}"
|
||||||
|
${CCBIN}
|
||||||
|
${nvcc_flags}
|
||||||
|
${nvcc_host_compiler_flags}
|
||||||
|
${CUDA_NVCC_FLAGS}
|
||||||
|
-DNVCC
|
||||||
|
${CUDA_NVCC_INCLUDE_ARGS}
|
||||||
|
)
|
||||||
|
|
||||||
|
if(CUDA_result)
|
||||||
|
# Since nvcc can sometimes leave half done files make sure that we delete the output file.
|
||||||
|
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()
|
||||||
|
|
||||||
|
# Cubin resource report commands.
|
||||||
|
if( build_cubin )
|
||||||
|
# Run with -cubin to produce resource usage report.
|
||||||
|
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}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Execute the parser script.
|
||||||
|
cuda_execute_process(
|
||||||
|
"Executing the parser script"
|
||||||
|
COMMAND "${CMAKE_COMMAND}"
|
||||||
|
-D "input_file:STRING=${generated_cubin_file}"
|
||||||
|
-P "${CUDA_parse_cubin}"
|
||||||
|
)
|
||||||
|
|
||||||
|
endif()
|
134
cmake/TargetArch.cmake
Executable file
134
cmake/TargetArch.cmake
Executable file
|
@ -0,0 +1,134 @@
|
||||||
|
# Based on the Qt 5 processor detection code, so should be very accurate
|
||||||
|
# https://qt.gitorious.org/qt/qtbase/blobs/master/src/corelib/global/qprocessordetection.h
|
||||||
|
# Currently handles arm (v5, v6, v7), x86 (32/64), ia64, and ppc (32/64)
|
||||||
|
|
||||||
|
# Regarding POWER/PowerPC, just as is noted in the Qt source,
|
||||||
|
# "There are many more known variants/revisions that we do not handle/detect."
|
||||||
|
|
||||||
|
set(archdetect_c_code "
|
||||||
|
#if defined(__arm__) || defined(__TARGET_ARCH_ARM)
|
||||||
|
#if defined(__ARM_ARCH_7__) \\
|
||||||
|
|| defined(__ARM_ARCH_7A__) \\
|
||||||
|
|| defined(__ARM_ARCH_7R__) \\
|
||||||
|
|| defined(__ARM_ARCH_7M__) \\
|
||||||
|
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 7)
|
||||||
|
#error cmake_ARCH armv7
|
||||||
|
#elif defined(__ARM_ARCH_6__) \\
|
||||||
|
|| defined(__ARM_ARCH_6J__) \\
|
||||||
|
|| defined(__ARM_ARCH_6T2__) \\
|
||||||
|
|| defined(__ARM_ARCH_6Z__) \\
|
||||||
|
|| defined(__ARM_ARCH_6K__) \\
|
||||||
|
|| defined(__ARM_ARCH_6ZK__) \\
|
||||||
|
|| defined(__ARM_ARCH_6M__) \\
|
||||||
|
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 6)
|
||||||
|
#error cmake_ARCH armv6
|
||||||
|
#elif defined(__ARM_ARCH_5TEJ__) \\
|
||||||
|
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 5)
|
||||||
|
#error cmake_ARCH armv5
|
||||||
|
#else
|
||||||
|
#error cmake_ARCH arm
|
||||||
|
#endif
|
||||||
|
#elif defined(__i386) || defined(__i386__) || defined(_M_IX86)
|
||||||
|
#error cmake_ARCH i386
|
||||||
|
#elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64)
|
||||||
|
#error cmake_ARCH x86_64
|
||||||
|
#elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64)
|
||||||
|
#error cmake_ARCH ia64
|
||||||
|
#elif defined(__ppc__) || defined(__ppc) || defined(__powerpc__) \\
|
||||||
|
|| defined(_ARCH_COM) || defined(_ARCH_PWR) || defined(_ARCH_PPC) \\
|
||||||
|
|| defined(_M_MPPC) || defined(_M_PPC)
|
||||||
|
#if defined(__ppc64__) || defined(__powerpc64__) || defined(__64BIT__)
|
||||||
|
#error cmake_ARCH ppc64
|
||||||
|
#else
|
||||||
|
#error cmake_ARCH ppc
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#error cmake_ARCH unknown
|
||||||
|
")
|
||||||
|
|
||||||
|
# Set ppc_support to TRUE before including this file or ppc and ppc64
|
||||||
|
# will be treated as invalid architectures since they are no longer supported by Apple
|
||||||
|
|
||||||
|
function(target_architecture output_var)
|
||||||
|
if(APPLE AND CMAKE_OSX_ARCHITECTURES)
|
||||||
|
# On OS X we use CMAKE_OSX_ARCHITECTURES *if* it was set
|
||||||
|
# First let's normalize the order of the values
|
||||||
|
|
||||||
|
# Note that it's not possible to compile PowerPC applications if you are using
|
||||||
|
# the OS X SDK version 10.6 or later - you'll need 10.4/10.5 for that, so we
|
||||||
|
# disable it by default
|
||||||
|
# See this page for more information:
|
||||||
|
# http://stackoverflow.com/questions/5333490/how-can-we-restore-ppc-ppc64-as-well-as-full-10-4-10-5-sdk-support-to-xcode-4
|
||||||
|
|
||||||
|
# Architecture defaults to i386 or ppc on OS X 10.5 and earlier, depending on the CPU type detected at runtime.
|
||||||
|
# On OS X 10.6+ the default is x86_64 if the CPU supports it, i386 otherwise.
|
||||||
|
|
||||||
|
foreach(osx_arch ${CMAKE_OSX_ARCHITECTURES})
|
||||||
|
if("${osx_arch}" STREQUAL "ppc" AND ppc_support)
|
||||||
|
set(osx_arch_ppc TRUE)
|
||||||
|
elseif("${osx_arch}" STREQUAL "i386")
|
||||||
|
set(osx_arch_i386 TRUE)
|
||||||
|
elseif("${osx_arch}" STREQUAL "x86_64")
|
||||||
|
set(osx_arch_x86_64 TRUE)
|
||||||
|
elseif("${osx_arch}" STREQUAL "ppc64" AND ppc_support)
|
||||||
|
set(osx_arch_ppc64 TRUE)
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Invalid OS X arch name: ${osx_arch}")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# Now add all the architectures in our normalized order
|
||||||
|
if(osx_arch_ppc)
|
||||||
|
list(APPEND ARCH ppc)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(osx_arch_i386)
|
||||||
|
list(APPEND ARCH i386)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(osx_arch_x86_64)
|
||||||
|
list(APPEND ARCH x86_64)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(osx_arch_ppc64)
|
||||||
|
list(APPEND ARCH ppc64)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
file(WRITE "${CMAKE_BINARY_DIR}/arch.c" "${archdetect_c_code}")
|
||||||
|
|
||||||
|
enable_language(C)
|
||||||
|
|
||||||
|
# Detect the architecture in a rather creative way...
|
||||||
|
# This compiles a small C program which is a series of ifdefs that selects a
|
||||||
|
# particular #error preprocessor directive whose message string contains the
|
||||||
|
# target architecture. The program will always fail to compile (both because
|
||||||
|
# file is not a valid C program, and obviously because of the presence of the
|
||||||
|
# #error preprocessor directives... but by exploiting the preprocessor in this
|
||||||
|
# way, we can detect the correct target architecture even when cross-compiling,
|
||||||
|
# since the program itself never needs to be run (only the compiler/preprocessor)
|
||||||
|
try_run(
|
||||||
|
run_result_unused
|
||||||
|
compile_result_unused
|
||||||
|
"${CMAKE_BINARY_DIR}"
|
||||||
|
"${CMAKE_BINARY_DIR}/arch.c"
|
||||||
|
COMPILE_OUTPUT_VARIABLE ARCH
|
||||||
|
CMAKE_FLAGS CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Parse the architecture name from the compiler output
|
||||||
|
string(REGEX MATCH "cmake_ARCH ([a-zA-Z0-9_]+)" ARCH "${ARCH}")
|
||||||
|
|
||||||
|
# Get rid of the value marker leaving just the architecture name
|
||||||
|
string(REPLACE "cmake_ARCH " "" ARCH "${ARCH}")
|
||||||
|
|
||||||
|
# If we are compiling with an unknown architecture this variable should
|
||||||
|
# already be set to "unknown" but in the case that it's empty (i.e. due
|
||||||
|
# to a typo in the code), then set it to unknown
|
||||||
|
if (NOT ARCH)
|
||||||
|
set(ARCH unknown)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(${output_var} "${ARCH}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
23
cmake/templates/build.info.in
Normal file
23
cmake/templates/build.info.in
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
%YAML:1.0
|
||||||
|
---
|
||||||
|
HOST_OS: "@HOST_OS@"
|
||||||
|
HOST_NAME: "@HOST_NAME@"
|
||||||
|
HOST_ARCH: "@HOST_ARCH@"
|
||||||
|
GCC_VERSION: "@GCC_VERSION@"
|
||||||
|
GCC_VERSION_MAJOR: @GCC_VERSION_MAJOR@
|
||||||
|
GCC_VERSION_MINOR: @GCC_VERSION_MINOR@
|
||||||
|
CUDA_VERSION: "@CUDA_VERSION@"
|
||||||
|
CUDA_VERSION_MAJOR: @CUDA_VERSION_MAJOR@
|
||||||
|
CUDA_VERSION_MINOR: @CUDA_VERSION_MINOR@
|
||||||
|
CUDA_VERSION_STRING: "@CUDA_VERSION_STRING@"
|
||||||
|
OpenCV_VERSION: "@OpenCV_VERSION@"
|
||||||
|
OpenCV_VERSION_MAJOR: @OpenCV_VERSION_MAJOR@
|
||||||
|
OpenCV_VERSION_MINOR: @OpenCV_VERSION_MINOR@
|
||||||
|
OpenCV_VERSION_PATCH: @OpenCV_VERSION_PATCH@
|
||||||
|
OpenCV_VERSION_TWEAK: @OpenCV_VERSION_TWEAK@
|
||||||
|
OpenCV_VERSION_STATUS: "@OpenCV_VERSION_STATUS@"
|
||||||
|
MYNTEYE_VERSION: "@mynteye_VERSION@"
|
||||||
|
MYNTEYE_VERSION_MAJOR: @mynteye_VERSION_MAJOR@
|
||||||
|
MYNTEYE_VERSION_MINOR: @mynteye_VERSION_MINOR@
|
||||||
|
MYNTEYE_VERSION_PATCH: @mynteye_VERSION_PATCH@
|
||||||
|
MYNTEYE_VERSION_TWEAK: @mynteye_VERSION_TWEAK@
|
Loading…
Reference in New Issue
Block a user