Commit d8eb0172 authored by Pierre Kraemer's avatar Pierre Kraemer

add new version of OpenNL (with CHOLMOD support)

parent 601d62f3
PROJECT(CUDA_DISCOVER_DEVICE_FLAGS)
if(COMMAND cmake_minimum_required)
cmake_minimum_required(VERSION 2.4)
endif(COMMAND cmake_minimum_required)
INCLUDE(${CMAKE_SOURCE_DIR}/../CMakeModules/FindCUDA.cmake)
SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${CMAKE_ANSI_CXXFLAGS})
SET(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} ${CMAKE_ANSI_CFLAGS})
INCLUDE_DIRECTORIES(${CMAKE_ROOT}/include ${CMAKE_ROOT}/Source)
CUDA_ADD_LIBRARY(cmCUDA_DISCOVER_DEVICE_FLAGS MODULE cmCUDA_DISCOVER_DEVICE_FLAGS.cpp)
#include <fstream>
#include <sstream>
#include <string>
#if WIN32
#include <windows.h>
#else
//#include <iostream>
#include <dirent.h>
#include <sys/stat.h>
#endif /*WIN32*/
#include "cmCPluginAPI.h"
#include <cuda.h>
#include <cuda_runtime_api.h>
class FlagBuilder{
public:
void add_flag(const std::string& flag){
oss << "-D" << flag << ";";
}
template <typename T> void add_def(const std::string& def, const T value){
oss << "-D" << def << "=" << value << ";";
}
std::string str(){
return oss.str();
}
private:
std::ostringstream oss;
};
FlagBuilder fb;
// Check if there is a device supporting CUDA
void GetCUDADeviceFlags()
{
int deviceCount;
bool archi_13 = false;
cudaGetDeviceCount(&deviceCount);
// This function call returns 0 if there are no CUDA capable devices.
if (deviceCount == 0)
printf("There is no device supporting CUDA\n");
int dev = 0;
for (dev = 0; dev < 1/*deviceCount/*HACK : we want the first one only for now*/; ++dev) {
printf("\nFirst device is selected by default.\n\n");
cudaDeviceProp deviceProp;
cudaGetDeviceProperties(&deviceProp, dev);
if (dev == 0) {
// This function call returns 9999 for both major & minor fields, if no CUDA capable devices are present
if (deviceProp.major == 9999 && deviceProp.minor == 9999)
printf("There is no device supporting CUDA.\n");
else if (deviceCount == 1)
printf("There is 1 device supporting CUDA\n");
else
printf("There are %d devices supporting CUDA\n", deviceCount);
if ((deviceProp.major * 10 + deviceProp.minor) >= 13 ) {
// OK on peut faire du double et rajouter des optimizations
archi_13 = true;
}
#if CUDART_VERSION >= 2000
if (archi_13){
fb.add_def("MAX_THREADS", deviceProp.multiProcessorCount*1024);
} else {
fb.add_def("MAX_THREADS", deviceProp.multiProcessorCount*768);
}
#endif
fb.add_def("WARP_SIZE", deviceProp.warpSize);
fb.add_flag("USE_CRS_SHARED");
fb.add_flag("USE_TEXTURE");
}
printf("\nDevice %d: \"%s\"\n", dev, deviceProp.name);
#if CUDART_VERSION >= 2020
int driverVersion = 0, runtimeVersion = 0;
cudaDriverGetVersion(&driverVersion);
printf(" CUDA Driver Version: %d.%d\n", driverVersion/1000, driverVersion%100);
cudaRuntimeGetVersion(&runtimeVersion);
printf(" CUDA Runtime Version: %d.%d\n", runtimeVersion/1000, runtimeVersion%100);
#endif
printf(" CUDA Capability Major revision number: %d\n", deviceProp.major);
printf(" CUDA Capability Minor revision number: %d\n", deviceProp.minor);
printf(" Total amount of global memory: %u bytes\n", deviceProp.totalGlobalMem);
#if CUDART_VERSION >= 2000
printf(" Number of multiprocessors: %d\n", deviceProp.multiProcessorCount);
printf(" Number of cores: %d\n", 8 * deviceProp.multiProcessorCount);
#endif
printf(" Total amount of constant memory: %u bytes\n", deviceProp.totalConstMem);
printf(" Total amount of shared memory per block: %u bytes\n", deviceProp.sharedMemPerBlock);
printf(" Total number of registers available per block: %d\n", deviceProp.regsPerBlock);
printf(" Warp size: %d\n", deviceProp.warpSize);
printf(" Warp size: %d\n", deviceProp.warpSize);
printf(" Maximum number of threads per block: %d\n", deviceProp.maxThreadsPerBlock);
printf(" Maximum sizes of each dimension of a block: %d x %d x %d\n",
deviceProp.maxThreadsDim[0],
deviceProp.maxThreadsDim[1],
deviceProp.maxThreadsDim[2]);
printf(" Maximum sizes of each dimension of a grid: %d x %d x %d\n",
deviceProp.maxGridSize[0],
deviceProp.maxGridSize[1],
deviceProp.maxGridSize[2]);
printf(" Maximum memory pitch: %u bytes\n", deviceProp.memPitch);
printf(" Texture alignment: %u bytes\n", deviceProp.textureAlignment);
printf(" Clock rate: %.2f GHz\n", deviceProp.clockRate * 1e-6f);
#if CUDART_VERSION >= 2000
printf(" Concurrent copy and execution: %s\n", deviceProp.deviceOverlap ? "Yes" : "No");
#endif
#if CUDART_VERSION >= 2020
printf(" Run time limit on kernels: %s\n", deviceProp.kernelExecTimeoutEnabled ? "Yes" : "No");
printf(" Integrated: %s\n", deviceProp.integrated ? "Yes" : "No");
printf(" Support host page-locked memory mapping: %s\n", deviceProp.canMapHostMemory ? "Yes" : "No");
printf(" Compute mode: %s\n", deviceProp.computeMode == cudaComputeModeDefault ?
"Default (multiple host threads can use this device simultaneously)" :
deviceProp.computeMode == cudaComputeModeExclusive ?
"Exclusive (only one host thread at a time can use this device)" :
deviceProp.computeMode == cudaComputeModeProhibited ?
"Prohibited (no host thread can use this device)" :
"Unknown");
#endif
}
}
#ifdef __cplusplus
extern "C" {
#endif
static int InitialPass(void *inf, void *mf, int argc, char *argv[])
{
cmLoadedCommandInfo *info = (cmLoadedCommandInfo *)(inf);
const char *pwd = info->CAPI->GetCurrentDirectory(mf);
info->CAPI->DisplaySatus(mf, pwd);
GetCUDADeviceFlags();
info->CAPI->DisplaySatus(mf, fb.str().c_str());
info->CAPI->AddDefinition(mf, "CUDA_DEVICE_FLAGS", fb.str().c_str());
return 1;
}
void CM_PLUGIN_EXPORT
CUDA_DISCOVER_DEVICE_FLAGSInit(cmLoadedCommandInfo *info)
{
info->InitialPass = InitialPass;
info->m_Inherited = 0;
info->Name = "CUDA_DISCOVER_DEVICE_FLAGS";
}
#ifdef __cplusplus
}
#endif
######################################
# CMake version checks
######################################
if(COMMAND cmake_minimum_required)
cmake_minimum_required(VERSION 2.4)
endif(COMMAND cmake_minimum_required)
if(COMMAND cmake_policy)
if(POLICY CMP0003)
cmake_policy(SET CMP0003 OLD)
endif(POLICY CMP0003)
if(POLICY CMP0005)
cmake_policy(SET CMP0005 OLD)
endif(POLICY CMP0005)
if(POLICY CMP0011)
cmake_policy(SET CMP0011 OLD) # or NEW
endif(POLICY CMP0011)
endif(COMMAND cmake_policy)
######################################
# Project
######################################
PROJECT(OpenNL3)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fPIC")
#SET(GEEX_BUILD_PATH ${PROJECT_BINARY_DIR})
#SET(BINARIES_RELATIVE_PATH /binaries/bin/)
#IF (WIN32)
# SET(LIBRARIES_RELATIVE_PATH /binaries/bin/)
#ELSE(WIN32)
# SET(LIBRARIES_RELATIVE_PATH /binaries/lib/)
#ENDIF(WIN32)
#IF(WIN32)
# SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}${BINARIES_RELATIVE_PATH})
#ELSE(WIN32)
# SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}${LIBRARIES_RELATIVE_PATH})
#ENDIF(WIN32)
#SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}${BINARIES_RELATIVE_PATH})
IF (EXISTS ${CMAKE_SOURCE_DIR}/OpenNL/CMakeOptions.txt)
MESSAGE(INFO: "Using local options file: " ${CMAKE_SOURCE_DIR}/OpenNL/CMakeOptions.txt)
INCLUDE(${CMAKE_SOURCE_DIR}/OpenNL/CMakeOptions.txt)
ENDIF(EXISTS ${CMAKE_SOURCE_DIR}/OpenNL/CMakeOptions.txt)
IF(USE_CNC)
ADD_DEFINITIONS(-DNL_USE_CNC)
IF(CUDA_BUILD_EMULATION)
ADD_DEFINITIONS(-D__DEVICE_EMULATION__)
ENDIF(CUDA_BUILD_EMULATION)
IF(WIN32)
ADD_DEFINITIONS(-DOS_WIN)
ELSE(WIN32)
ADD_DEFINITIONS(-DOS_LINUX)
ENDIF(WIN32)
INCLUDE(${CMAKE_SOURCE_DIR}/OpenNL/CMakeModules/FindCUDA.cmake)
IF (CMAKE_BUILD_TYPE MATCHES Debug)
SET(CUDA_COMPILE_TIME_EXTRA_FLAGS -G)
ENDIF (CMAKE_BUILD_TYPE MATCHES Debug)
IF(CNC_OPTIMIZE_FOR_THIS_MACHINE)
IF(COMMAND CUDA_DISCOVER_DEVICE_FLAGS)
ELSE(COMMAND CUDA_DISCOVER_DEVICE_FLAGS)
TRY_COMPILE(COMPILE_OK ${PROJECT_BINARY_DIR}/CMake ${PROJECT_SOURCE_DIR}/CMake CUDA_DISCOVER_DEVICE_FLAGS)
IF(NOT COMPILE_OK)
IF(WIN32)
MESSAGE("error compiling CUDA_DISCOVER_DEVICE_FLAGS extention")
ELSE(WIN32)
MESSAGE(FATAL_ERROR "error compiling CUDA_DISCOVER_DEVICE_FLAGS extention")
ENDIF(WIN32)
ENDIF(NOT COMPILE_OK)
LOAD_COMMAND(CUDA_DISCOVER_DEVICE_FLAGS ${PROJECT_BINARY_DIR}/CMake ${PROJECT_BINARY_DIR}/CMake/Debug)
ENDIF(COMMAND CUDA_DISCOVER_DEVICE_FLAGS)
CUDA_DISCOVER_DEVICE_FLAGS()
SET(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} ${CUDA_DEVICE_FLAGS} )
ADD_DEFINITIONS(${CUDA_DEVICE_FLAGS})
ELSE(CNC_OPTIMIZE_FOR_THIS_MACHINE)
SET(CUDA_NVCC_FLAGS ${CNC_NVCC_FLAGS})
ENDIF(CNC_OPTIMIZE_FOR_THIS_MACHINE)
ENDIF(USE_CNC)
IF (CMAKE_BUILD_TYPE MATCHES Debug)
ADD_DEFINITIONS(-DNL_DEBUG)
IF(PARANOID_DEBUG)
ADD_DEFINITIONS(-DNL_PARANOID)
ENDIF(PARANOID_DEBUG)
ENDIF (CMAKE_BUILD_TYPE MATCHES Debug)
#########################################
# ADD HERE ADDITIONAL INCLUDE DIRECTORIES
#########################################
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
INCLUDE_DIRECTORIES(src)
#########################################
# ADD HERE SUBDIRECTORIES
#########################################
ADD_SUBDIRECTORY(src)
IF(BUILD_EXAMPLES)
ADD_SUBDIRECTORY(examples)
ENDIF(BUILD_EXAMPLES)
IF(WIN32)
MESSAGE("Configure done. You may need to click on configure again if the OK button is disabled")
ENDIF(WIN32)
# - Tools for building CUDA C files: libraries and build dependencies.
# This script locates the NVIDIA CUDA C tools. It should work on linux, windows,
# and mac and should be reasonably up to date with CUDA C releases.
#
# This script makes use of the standard find_package arguments of <VERSION>,
# REQUIRED and QUIET. CUDA_FOUND will report if an acceptable version of CUDA
# was found.
#
# The script will prompt the user to specify CUDA_TOOLKIT_ROOT_DIR if the prefix
# cannot be determined by the location of nvcc in the system path and REQUIRED
# is specified to find_package(). To use a different installed version of the
# toolkit set the environment variable CUDA_BIN_PATH before running cmake
# (e.g. CUDA_BIN_PATH=/usr/local/cuda1.0 instead of the default /usr/local/cuda)
# or set CUDA_TOOLKIT_ROOT_DIR after configuring. If you change the value of
# CUDA_TOOLKIT_ROOT_DIR, various components that depend on the path will be
# relocated.
#
# It might be necessary to set CUDA_TOOLKIT_ROOT_DIR manually on certain
# platforms, or to use a cuda runtime not installed in the default location. In
# newer versions of the toolkit the cuda library is included with the graphics
# driver- be sure that the driver version matches what is needed by the cuda
# runtime version.
#
# The following variables affect the behavior of the macros in the script (in
# alphebetical order). Note that any of these flags can be changed multiple
# times in the same directory before calling CUDA_ADD_EXECUTABLE,
# CUDA_ADD_LIBRARY, CUDA_COMPILE, CUDA_COMPILE_PTX or CUDA_WRAP_SRCS.
#
# CUDA_64_BIT_DEVICE_CODE (Default matches host bit size)
# -- Set to ON to compile for 64 bit device code, OFF for 32 bit device code.
# Note that making this different from the host code when generating object
# or C files from CUDA code just won't work, because size_t gets defined by
# nvcc in the generated source. If you compile to PTX and then load the
# file yourself, you can mix bit sizes between device and host.
#
# CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE (Default ON)
# -- Set to ON if you want the custom build rule to be attached to the source
# file in Visual Studio. Turn OFF if you add the same cuda file to multiple
# targets.
#
# This allows the user to build the target from the CUDA file; however, bad
# things can happen if the CUDA source file is added to multiple targets.
# When performing parallel builds it is possible for the custom build
# command to be run more than once and in parallel causing cryptic build
# errors. VS runs the rules for every source file in the target, and a
# source can have only one rule no matter how many projects it is added to.
# When the rule is run from multiple targets race conditions can occur on
# the generated file. Eventually everything will get built, but if the user
# is unaware of this behavior, there may be confusion. It would be nice if
# this script could detect the reuse of source files across multiple targets
# and turn the option off for the user, but no good solution could be found.
#
# CUDA_BUILD_CUBIN (Default OFF)
# -- Set to ON to enable and extra compilation pass with the -cubin option in
# Device mode. The output is parsed and register, shared memory usage is
# printed during build.
#
# CUDA_BUILD_EMULATION (Default OFF for device mode)
# -- Set to ON for Emulation mode. -D_DEVICEEMU is defined for CUDA C files
# when CUDA_BUILD_EMULATION is TRUE.
#
# CUDA_GENERATED_OUTPUT_DIR (Default CMAKE_CURRENT_BINARY_DIR)
# -- Set to the path you wish to have the generated files placed. If it is
# blank output files will be placed in CMAKE_CURRENT_BINARY_DIR.
# Intermediate files will always be placed in
# CMAKE_CURRENT_BINARY_DIR/CMakeFiles.
#
# CUDA_HOST_COMPILATION_CPP (Default ON)
# -- Set to OFF for C compilation of host code.
#
# CUDA_NVCC_FLAGS
# CUDA_NVCC_FLAGS_<CONFIG>
# -- Additional NVCC command line arguments. NOTE: multiple arguments must be
# semi-colon delimited (e.g. --compiler-options;-Wall)
#
# CUDA_PROPAGATE_HOST_FLAGS (Default ON)
# -- Set to ON to propagate CMAKE_{C,CXX}_FLAGS and their configuration
# dependent counterparts (e.g. CMAKE_C_FLAGS_DEBUG) automatically to the
# host compiler through nvcc's -Xcompiler flag. This helps make the
# generated host code match the rest of the system better. Sometimes
# certain flags give nvcc problems, and this will help you turn the flag
# propagation off. This does not affect the flags supplied directly to nvcc
# via CUDA_NVCC_FLAGS or through the OPTION flags specified through
# CUDA_ADD_LIBRARY, CUDA_ADD_EXECUTABLE, or CUDA_WRAP_SRCS. Flags used for
# shared library compilation are not affected by this flag.
#
# CUDA_VERBOSE_BUILD (Default OFF)
# -- Set to ON to see all the commands used when building the CUDA file. When
# using a Makefile generator the value defaults to VERBOSE (run make
# VERBOSE=1 to see output), although setting CUDA_VERBOSE_BUILD to ON will
# always print the output.
#
# The script creates the following macros (in alphebetical order):
#
# CUDA_ADD_CUFFT_TO_TARGET( cuda_target )
# -- Adds the cufft library to the target (can be any target). Handles whether
# you are in emulation mode or not.
#
# CUDA_ADD_CUBLAS_TO_TARGET( cuda_target )
# -- Adds the cublas library to the target (can be any target). Handles
# whether you are in emulation mode or not.
#
# CUDA_ADD_EXECUTABLE( cuda_target file0 file1 ...
# [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] [OPTIONS ...] )
# -- Creates an executable "cuda_target" which is made up of the files
# specified. All of the non CUDA C files are compiled using the standard
# build rules specified by CMAKE and the cuda files are compiled to object
# files using nvcc and the host compiler. In addition CUDA_INCLUDE_DIRS is
# added automatically to include_directories(). Standard CMake target calls
# can be used on the target after calling this macro
# (e.g. set_target_properties and target_link_libraries).
#
# CUDA_ADD_LIBRARY( cuda_target file0 file1 ...
# [STATIC | SHARED | MODULE] [EXCLUDE_FROM_ALL] [OPTIONS ...] )
# -- Same as CUDA_ADD_EXECUTABLE except that a library is created.
#
# CUDA_BUILD_CLEAN_TARGET()
# -- Creates a convience target that deletes all the dependency files
# generated. You should make clean after running this target to ensure the
# dependency files get regenerated.
#
# CUDA_COMPILE( generated_files file0 file1 ... [STATIC | SHARED | MODULE]
# [OPTIONS ...] )
# -- Returns a list of generated files from the input source files to be used
# with ADD_LIBRARY or ADD_EXECUTABLE.
#
# CUDA_COMPILE_PTX( generated_files file0 file1 ... [OPTIONS ...] )
# -- Returns a list of PTX files generated from the input source files.
#
# CUDA_INCLUDE_DIRECTORIES( path0 path1 ... )
# -- Sets the directories that should be passed to nvcc
# (e.g. nvcc -Ipath0 -Ipath1 ... ). These paths usually contain other .cu
# files.
#
# CUDA_WRAP_SRCS ( cuda_target format generated_files file0 file1 ...
# [STATIC | SHARED | MODULE] [OPTIONS ...] )
# -- This is where all the magic happens. CUDA_ADD_EXECUTABLE,
# CUDA_ADD_LIBRARY, CUDA_COMPILE, and CUDA_COMPILE_PTX all call this
# function under the hood.
#
# Given the list of files (file0 file1 ... fileN) this macro generates
# custom commands that generate either PTX or linkable objects (use "PTX" or
# "OBJ" for the format argument to switch). Files that don't end with .cu
# or have the HEADER_FILE_ONLY property are ignored.
#
# The arguments passed in after OPTIONS are extra command line options to
# give to nvcc. You can also specify per configuration options by
# specifying the name of the configuration followed by the options. General
# options must preceed configuration specific options. Not all
# configurations need to be specified, only the ones provided will be used.
#
# OPTIONS -DFLAG=2 "-DFLAG_OTHER=space in flag"
# DEBUG -g
# RELEASE --use_fast_math
# RELWITHDEBINFO --use_fast_math;-g
# MINSIZEREL --use_fast_math
#
# For certain configurations (namely VS generating object files with
# CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE set to ON), no generated file will
# be produced for the given cuda file. This is because when you add the
# cuda file to Visual Studio it knows that this file produces an object file
# and will link in the resulting object file automatically.
#
# This script will also generate a separate cmake script that is used at
# build time to invoke nvcc. This is for serveral reasons.
#
# 1. nvcc can return negative numbers as return values which confuses
# Visual Studio into thinking that the command succeeded. The script now
# checks the error codes and produces errors when there was a problem.
#
# 2. nvcc has been known to not delete incomplete results when it
# encounters problems. This confuses build systems into thinking the
# target was generated when in fact an unusable file exists. The script
# now deletes the output files if there was an error.
#
# 3. By putting all the options that affect the build into a file and then
# make the build rule dependent on the file, the output files will be
# regenerated when the options change.
#
# This script also looks at optional arguments STATIC, SHARED, or MODULE to
# determine when to target the object compilation for a shared library.
# BUILD_SHARED_LIBS is ignored in CUDA_WRAP_SRCS, but it is respected in
# CUDA_ADD_LIBRARY. On some systems special flags are added for building
# objects intended for shared libraries. A preprocessor macro,
# <target_name>_EXPORTS is defined when a shared library compilation is
# detected.
#
# Flags passed into add_definitions with -D or /D are passed along to nvcc.
#
# The script defines the following variables:
#
# CUDA_VERSION_MAJOR -- The major version of cuda as reported by nvcc.
# CUDA_VERSION_MINOR -- The minor version.
# CUDA_VERSION
# CUDA_VERSION_STRING -- CUDA_VERSION_MAJOR.CUDA_VERSION_MINOR
#
# CUDA_TOOLKIT_ROOT_DIR -- Path to the CUDA Toolkit (defined if not set).
# CUDA_SDK_ROOT_DIR -- Path to the CUDA SDK. Use this to find files in the
# SDK. This script will not directly support finding
# specific libraries or headers, as that isn't
# supported by NVIDIA. If you want to change
# libraries when the path changes see the
# FindCUDA.cmake script for an example of how to clear
# these variables. There are also examples of how to
# use the CUDA_SDK_ROOT_DIR to locate headers or
# libraries, if you so choose (at your own risk).
# CUDA_INCLUDE_DIRS -- Include directory for cuda headers. Added automatically
# for CUDA_ADD_EXECUTABLE and CUDA_ADD_LIBRARY.
# CUDA_LIBRARIES -- Cuda RT library.
# CUDA_CUFFT_LIBRARIES -- Device or emulation library for the Cuda FFT
# implementation (alternative to:
# CUDA_ADD_CUFFT_TO_TARGET macro)
# CUDA_CUBLAS_LIBRARIES -- Device or emulation library for the Cuda BLAS
# implementation (alterative to:
# CUDA_ADD_CUBLAS_TO_TARGET macro).
#
#
# 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.
#
###############################################################################
# FindCUDA.cmake
# We need to have at least this version to support the VERSION_LESS argument to 'if' (2.6.2) and unset (2.6.3)
cmake_policy(PUSH)
cmake_minimum_required(VERSION 2.6.3)
cmake_policy(POP)
# This macro helps us find the location of helper files we will need the full path to
macro(CUDA_FIND_HELPER_FILE _name _extension)
set(_full_name "${_name}.${_extension}")
# CMAKE_CURRENT_LIST_FILE contains the full path to the file currently being
# processed. Using this variable, we can pull out the current path, and
# provide a way to get access to the other files we need local to here.
get_filename_component(CMAKE_CURRENT_LIST_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
find_file(CUDA_${_name} ${_full_name} PATHS ${CMAKE_CURRENT_LIST_DIR}/FindCUDA NO_DEFAULT_PATH)
if(NOT CUDA_${_name})
set(error_message "${_full_name} not found in CMAKE_MODULE_PATH")
if(CUDA_FIND_REQUIRED)
message(FATAL_ERROR "${error_message}")
else(CUDA_FIND_REQUIRED)
if(NOT CUDA_FIND_QUIETLY)
message(STATUS "${error_message}")
endif(NOT CUDA_FIND_QUIETLY)
endif(CUDA_FIND_REQUIRED)
endif(NOT CUDA_${_name})
# Set this variable as internal, so the user isn't bugged with it.
set(CUDA_${_name} ${CUDA_${_name}} CACHE INTERNAL "Location of ${_full_name}" FORCE)
endmacro(CUDA_FIND_HELPER_FILE)
#####################################################################
## CUDA_INCLUDE_NVCC_DEPENDENCIES
##
# So we want to try and include the dependency file if it exists. If
# it doesn't exist then we need to create an empty one, so we can
# include it.
# If it does exist, then we need to check to see if all the files it
# depends on exist. If they don't then we should clear the dependency
# file and regenerate it later. This covers the case where a header
# file has disappeared or moved.
macro(CUDA_INCLUDE_NVCC_DEPENDENCIES dependency_file)
set(CUDA_NVCC_DEPEND)
set(CUDA_NVCC_DEPEND_REGENERATE FALSE)
# Include the dependency file. Create it first if it doesn't exist . The
# INCLUDE puts a dependency that will force CMake to rerun and bring in the
# new info when it changes. DO NOT REMOVE THIS (as I did and spent a few
# hours figuring out why it didn't work.
if(NOT EXISTS ${dependency_file})
file(WRITE ${dependency_file} "#FindCUDA.cmake generated file. Do not edit.\n")
endif()
# Always include this file to force CMake to run again next