Permalink
Browse files

Add a CMake build system (with CUDA support)

This patch adds a simple CMake build system. I have also included the required
magic to support the CUDA runtime if present.
  • Loading branch information...
1 parent 68e9c26 commit f0bb20a8a183da69dece24b5f657e3e988aab441 @rjw57 committed Nov 19, 2009
View
@@ -0,0 +1,57 @@
+# CMake project file for CUDA example.
+#
+# Copyright (C) 2009 Rich Wareham <richwareham@gmail.com>
+#
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# * Neither the name of the <organization> nor the
+# names of its contributors may be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY RICH WAREHAM ''AS IS'' AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL RICH WAREHAM BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# Update the module path to include any extra CMAKE modiles we might ship.
+SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
+
+# This project is called CUDAEXAMPLE
+PROJECT(CUDAEXAMPLE CUDA C CXX)
+
+# Set the minimum required version of cmake
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+# Enable warnings and make them errors
+# Also enable optimisation
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O9 -Wall -Werror")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O9 -Wall -Werror")
+
+# On x86_64 we need to compile with -fPIC
+IF(UNIX AND NOT WIN32)
+ FIND_PROGRAM(CMAKE_UNAME uname /bin /usr/bin /usr/local/bin )
+ IF(CMAKE_UNAME)
+ EXEC_PROGRAM(uname ARGS -m OUTPUT_VARIABLE CMAKE_SYSTEM_PROCESSOR)
+ SET(CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR}
+ CACHE INTERNAL "processor type (i386 and x86_64)")
+ IF(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
+ ADD_DEFINITIONS(-fPIC)
+ ENDIF(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
+ ENDIF(CMAKE_UNAME)
+ENDIF(UNIX AND NOT WIN32)
+
+# The landing predictor itself
+add_subdirectory(pred_src)
View
@@ -1,31 +0,0 @@
-PKG_CONFIG_PACKAGES=glib-2.0
-LDFLAGS=-lm `pkg-config ${PKG_CONFIG_PACKAGES} --libs`
-CFLAGS=-Wall -g `pkg-config ${PKG_CONFIG_PACKAGES} --cflags`
-
-PRED_OBJECTS = \
- pred_src/pred.o \
- pred_src/run_model.o \
- pred_src/altitude.o \
- pred_src/ini/dictionary.o \
- pred_src/ini/iniparser.o \
- pred_src/util/getline.o \
- pred_src/util/getdelim.o \
- pred_src/util/gopt.o \
- pred_src/util/random.o \
- pred_src/wind/wind_file_cache.o \
- pred_src/wind/wind_file.o
-
-PRED_EXECUTABLE=pred
-
-all: $(PRED_EXECUTABLE) test
-
-$(PRED_EXECUTABLE): $(PRED_OBJECTS)
- $(CC) $(LDFLAGS) $(PRED_OBJECTS) -o $@
-
-clean_pred:
- rm -rf $(PRED_OBJECTS) $(PRED_EXECUTABLE)
-
-clean: clean_pred
-
-test: $(PRED_EXECUTABLE) test/scenario.ini
- ./$(PRED_EXECUTABLE) -v -i test/gfs -t 1257951600 test/scenario.ini > test/output.csv
@@ -0,0 +1,13 @@
+# Modified from CMakeCCompiler.cmake.in
+
+SET(CMAKE_CUDA_COMPILER "@CMAKE_CUDA_COMPILER@")
+SET(CMAKE_CUDA_COMPILER_ARG1 "@CMAKE_CUDA_COMPILER_ARG1@")
+SET(CMAKE_CUDA_COMPILER_ID "@CMAKE_CUDA_COMPILER_ID@")
+SET(CMAKE_CUDA_PLATFORM_ID "@CMAKE_CUDA_PLATFORM_ID@")
+SET(CMAKE_CUDA_COMPILER_IS_NVCC_RUN @CMAKE_CUDA_COMPILER_IS_NVCC_RUN@)
+SET(CMAKE_CUDA_COMPILER_LOADED 1)
+SET(CMAKE_CUDA_COMPILER_ENV_VAR "NVCC")
+SET(CMAKE_CUDA_COMPILER_ID_RUN 1)
+SET(CMAKE_CUDA_SOURCE_FILE_EXTENSIONS cu)
+SET(CMAKE_CUDA_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC)
+SET(CMAKE_CUDA_LINKER_PREFERENCE 10)
@@ -0,0 +1,177 @@
+# Modified from CMakeCInformation.cmake
+
+# This file sets the basic flags for the CUDA language in CMake.
+# It also loads the available platform file for the system-compiler
+# if it exists.
+# It also loads a system - compiler - processor (or target hardware)
+# specific file, which is mainly useful for crosscompiling and embedded systems.
+
+# some compilers use different extensions (e.g. sdcc uses .rel)
+# so set the extension here first so it can be overridden by the compiler specific file
+IF(UNIX)
+ SET(CMAKE_CUDA_OUTPUT_EXTENSION .o)
+ELSE(UNIX)
+ SET(CMAKE_CUDA_OUTPUT_EXTENSION .obj)
+ENDIF(UNIX)
+
+GET_FILENAME_COMPONENT(CMAKE_BASE_NAME ${CMAKE_CUDA_COMPILER} NAME_WE)
+IF(CMAKE_COMPILER_IS_NVCC)
+ SET(CMAKE_BASE_NAME nvcc)
+ENDIF(CMAKE_COMPILER_IS_NVCC)
+
+
+# load a hardware specific file, mostly useful for embedded compilers
+IF(CMAKE_SYSTEM_PROCESSOR)
+ IF(CMAKE_CUDA_COMPILER_ID)
+ INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_CUDA_COMPILER_ID}-C-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
+ ENDIF(CMAKE_CUDA_COMPILER_ID)
+ IF (NOT _INCLUDED_FILE)
+ INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL)
+ ENDIF (NOT _INCLUDED_FILE)
+ENDIF(CMAKE_SYSTEM_PROCESSOR)
+
+
+# load the system- and compiler specific files
+IF(CMAKE_CUDA_COMPILER_ID)
+ INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_CUDA_COMPILER_ID}-C OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
+ENDIF(CMAKE_CUDA_COMPILER_ID)
+IF (NOT _INCLUDED_FILE)
+ INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL)
+ENDIF (NOT _INCLUDED_FILE)
+
+
+# This should be included before the _INIT variables are
+# used to initialize the cache. Since the rule variables
+# have if blocks on them, users can still define them here.
+# But, it should still be after the platform file so changes can
+# be made to those values.
+
+IF(CMAKE_USER_MAKE_RULES_OVERRIDE)
+ INCLUDE(${CMAKE_USER_MAKE_RULES_OVERRIDE})
+ENDIF(CMAKE_USER_MAKE_RULES_OVERRIDE)
+
+IF(CMAKE_USER_MAKE_RULES_OVERRIDE_C)
+ INCLUDE(${CMAKE_USER_MAKE_RULES_OVERRIDE_C})
+ENDIF(CMAKE_USER_MAKE_RULES_OVERRIDE_C)
+
+
+# for most systems a module is the same as a shared library
+# so unless the variable CMAKE_MODULE_EXISTS is set just
+# copy the values from the LIBRARY variables
+IF(NOT CMAKE_MODULE_EXISTS)
+ SET(CMAKE_SHARED_MODULE_CUDA_FLAGS ${CMAKE_SHARED_LIBRARY_CUDA_FLAGS})
+ SET(CMAKE_SHARED_MODULE_CREATE_CUDA_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_CUDA_FLAGS})
+ENDIF(NOT CMAKE_MODULE_EXISTS)
+
+SET(CMAKE_CUDA_FLAGS_INIT "$ENV{CFLAGS} ${CMAKE_CUDA_FLAGS_INIT}")
+# avoid just having a space as the initial value for the cache
+IF(CMAKE_CUDA_FLAGS_INIT STREQUAL " ")
+ SET(CMAKE_CUDA_FLAGS_INIT)
+ENDIF(CMAKE_CUDA_FLAGS_INIT STREQUAL " ")
+SET (CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS_INIT}" CACHE STRING
+ "Flags used by the compiler during all build types.")
+
+IF(NOT CMAKE_NOT_USING_CONFIG_FLAGS)
+# default build type is none
+ IF(NOT CMAKE_NO_BUILD_TYPE)
+ SET (CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE_INIT} CACHE STRING
+ "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_CUDA_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.")
+ ENDIF(NOT CMAKE_NO_BUILD_TYPE)
+ SET (CMAKE_CUDA_FLAGS_DEBUG "${CMAKE_CUDA_FLAGS_DEBUG_INIT}" CACHE STRING
+ "Flags used by the compiler during debug builds.")
+ SET (CMAKE_CUDA_FLAGS_MINSIZEREL "${CMAKE_CUDA_FLAGS_MINSIZEREL_INIT}" CACHE STRING
+ "Flags used by the compiler during release minsize builds.")
+ SET (CMAKE_CUDA_FLAGS_RELEASE "${CMAKE_CUDA_FLAGS_RELEASE_INIT}" CACHE STRING
+ "Flags used by the compiler during release builds (/MD /Ob1 /Oi /Ot /Oy /Gs will produce slightly less optimized but smaller files).")
+ SET (CMAKE_CUDA_FLAGS_RELWITHDEBINFO "${CMAKE_CUDA_FLAGS_RELWITHDEBINFO_INIT}" CACHE STRING
+ "Flags used by the compiler during Release with Debug Info builds.")
+ENDIF(NOT CMAKE_NOT_USING_CONFIG_FLAGS)
+
+IF(CMAKE_CUDA_STANDARD_LIBRARIES_INIT)
+ SET(CMAKE_CUDA_STANDARD_LIBRARIES "${CMAKE_CUDA_STANDARD_LIBRARIES_INIT}"
+ CACHE STRING "Libraries linked by defalut with all CUDA applications.")
+ MARK_AS_ADVANCED(CMAKE_CUDA_STANDARD_LIBRARIES)
+ENDIF(CMAKE_CUDA_STANDARD_LIBRARIES_INIT)
+
+INCLUDE(CMakeCommonLanguageInclude)
+
+SET(CMAKE_SHARED_LIBRARY_CUDA_FLAGS "") # -pic
+SET(CMAKE_SHARED_LIBRARY_CREATE_CUDA_FLAGS "-shared") # -shared
+SET(CMAKE_SHARED_LIBRARY_LINK_CUDA_FLAGS "") # +s, flag for exe link to use shared lib
+SET(CMAKE_SHARED_LIBRARY_RUNTIME_CUDA_FLAG "") # -rpath
+SET(CMAKE_SHARED_LIBRARY_RUNTIME_CUDA_FLAG_SEP "") # : or empty
+SET(CMAKE_INCLUDE_FLAG_CUDA "-I") # -I
+SET(CMAKE_INCLUDE_FLAG_CUDA_SEP "") # , or empty
+
+# now define the following rule variables
+
+# CMAKE_CUDA_CREATE_SHARED_LIBRARY
+# CMAKE_CUDA_CREATE_SHARED_MODULE
+# CMAKE_CUDA_COMPILE_OBJECT
+# CMAKE_CUDA_LINK_EXECUTABLE
+
+# variables supplied by the generator at use time
+# <TARGET>
+# <TARGET_BASE> the target without the suffix
+# <OBJECTS>
+# <OBJECT>
+# <LINK_LIBRARIES>
+# <FLAGS>
+# <LINK_FLAGS>
+
+# CUDA compiler information
+# <CMAKE_CUDA_COMPILER>
+# <CMAKE_SHARED_LIBRARY_CREATE_CUDA_FLAGS>
+# <CMAKE_SHARED_MODULE_CREATE_CUDA_FLAGS>
+# <CMAKE_CUDA_LINK_FLAGS>
+
+# create a CUDA shared library
+IF(NOT CMAKE_CUDA_CREATE_SHARED_LIBRARY)
+ SET(CMAKE_CUDA_CREATE_SHARED_LIBRARY
+ "<CMAKE_CUDA_COMPILER> <CMAKE_SHARED_LIBRARY_CUDA_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CUDA_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CUDA_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
+ENDIF(NOT CMAKE_CUDA_CREATE_SHARED_LIBRARY)
+
+# create a CUDA shared module just copy the shared library rule
+IF(NOT CMAKE_CUDA_CREATE_SHARED_MODULE)
+ SET(CMAKE_CUDA_CREATE_SHARED_MODULE ${CMAKE_CUDA_CREATE_SHARED_LIBRARY})
+ENDIF(NOT CMAKE_CUDA_CREATE_SHARED_MODULE)
+
+# Create a static archive incrementally for large object file counts.
+# If CMAKE_CUDA_CREATE_STATIC_LIBRARY is set it will override these.
+SET(CMAKE_CUDA_ARCHIVE_CREATE "<CMAKE_AR> cr <TARGET> <LINK_FLAGS> <OBJECTS>")
+SET(CMAKE_CUDA_ARCHIVE_APPEND "<CMAKE_AR> r <TARGET> <LINK_FLAGS> <OBJECTS>")
+SET(CMAKE_CUDA_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>")
+
+# compile a CUDA file into an object file
+IF(NOT CMAKE_CUDA_COMPILE_OBJECT)
+ SET(CMAKE_CUDA_COMPILE_OBJECT
+ "<CMAKE_CUDA_COMPILER> <DEFINES> <FLAGS> -o <OBJECT> -c <SOURCE>")
+ENDIF(NOT CMAKE_CUDA_COMPILE_OBJECT)
+
+IF(NOT CMAKE_CUDA_LINK_EXECUTABLE)
+ SET(CMAKE_CUDA_LINK_EXECUTABLE
+ "<CMAKE_CUDA_COMPILER> <FLAGS> <CMAKE_CUDA_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
+ENDIF(NOT CMAKE_CUDA_LINK_EXECUTABLE)
+
+IF(NOT CMAKE_EXECUTABLE_RUNTIME_CUDA_FLAG)
+ SET(CMAKE_EXECUTABLE_RUNTIME_CUDA_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_CUDA_FLAG})
+ENDIF(NOT CMAKE_EXECUTABLE_RUNTIME_CUDA_FLAG)
+
+IF(NOT CMAKE_EXECUTABLE_RUNTIME_CUDA_FLAG_SEP)
+ SET(CMAKE_EXECUTABLE_RUNTIME_CUDA_FLAG_SEP ${CMAKE_SHARED_LIBRARY_RUNTIME_CUDA_FLAG_SEP})
+ENDIF(NOT CMAKE_EXECUTABLE_RUNTIME_CUDA_FLAG_SEP)
+
+IF(NOT CMAKE_EXECUTABLE_RPATH_LINK_CUDA_FLAG)
+ SET(CMAKE_EXECUTABLE_RPATH_LINK_CUDA_FLAG ${CMAKE_SHARED_LIBRARY_RPATH_LINK_CUDA_FLAG})
+ENDIF(NOT CMAKE_EXECUTABLE_RPATH_LINK_CUDA_FLAG)
+
+MARK_AS_ADVANCED(
+CMAKE_CUDA_FLAGS
+CMAKE_CUDA_FLAGS_DEBUG
+CMAKE_CUDA_FLAGS_MINSIZEREL
+CMAKE_CUDA_FLAGS_RELEASE
+CMAKE_CUDA_FLAGS_RELWITHDEBINFO
+)
+SET(CMAKE_CUDA_INFORMATION_LOADED 1)
+
+
@@ -0,0 +1,64 @@
+# Modified from CMakeCInformation.cmake
+
+# determine the compiler to use for CUDA programs
+# NOTE, a generator may set CMAKE_CUDA_COMPILER before
+# loading this file to force a compiler.
+# use environment variable CUDAC first if defined by user, next use
+# the cmake variable CMAKE_GENERATOR_NVCC which can be defined by a generator
+# as a default compiler
+
+IF(NOT CMAKE_CUDA_COMPILER)
+ # prefer the environment variable NVCC
+ IF($ENV{CUDAC} MATCHES ".+")
+ GET_FILENAME_COMPONENT(CMAKE_CUDA_COMPILER_INIT $ENV{CUDAC} PROGRAM PROGRAM_ARGS CMAKE_CUDA_FLAGS_ENV_INIT)
+ IF(CMAKE_CUDA_FLAGS_ENV_INIT)
+ SET(CMAKE_CUDA_COMPILER_ARG1 "${CMAKE_CUDA_FLAGS_ENV_INIT}" CACHE STRING "First argument to CUDA compiler")
+ ENDIF(CMAKE_CUDA_FLAGS_ENV_INIT)
+ IF(EXISTS ${CMAKE_CUDA_COMPILER_INIT})
+ ELSE(EXISTS ${CMAKE_CUDA_COMPILER_INIT})
+ MESSAGE(FATAL_ERROR "Could not find compiler set in environment variable C:\n$ENV{CUDAC}.")
+ ENDIF(EXISTS ${CMAKE_CUDA_COMPILER_INIT})
+ ENDIF($ENV{CUDAC} MATCHES ".+")
+
+ # next try prefer the compiler specified by the generator
+ IF(CMAKE_GENERATOR_NVCC)
+ IF(NOT CMAKE_CUDA_COMPILER_INIT)
+ SET(CMAKE_CUDA_COMPILER_INIT ${CMAKE_GENERATOR_NVCC})
+ ENDIF(NOT CMAKE_CUDA_COMPILER_INIT)
+ ENDIF(CMAKE_GENERATOR_NVCC)
+
+ # finally list compilers to try
+ IF(CMAKE_CUDA_COMPILER_INIT)
+ SET(CMAKE_CUDA_COMPILER_LIST ${CMAKE_CUDA_COMPILER_INIT})
+ ELSE(CMAKE_CUDA_COMPILER_INIT)
+ SET(CMAKE_CUDA_COMPILER_LIST nvcc)
+ ENDIF(CMAKE_CUDA_COMPILER_INIT)
+
+ # Find the compiler.
+ FIND_PROGRAM(CMAKE_CUDA_COMPILER NAMES ${CMAKE_CUDA_COMPILER_LIST} DOC "CUDA compiler")
+ IF(CMAKE_CUDA_COMPILER_INIT AND NOT CMAKE_CUDA_COMPILER)
+ SET(CMAKE_CUDA_COMPILER "${CMAKE_CUDA_COMPILER_INIT}" CACHE FILEPATH "CUDA compiler" FORCE)
+ ENDIF(CMAKE_CUDA_COMPILER_INIT AND NOT CMAKE_CUDA_COMPILER)
+ENDIF(NOT CMAKE_CUDA_COMPILER)
+MARK_AS_ADVANCED(CMAKE_CUDA_COMPILER)
+GET_FILENAME_COMPONENT(COMPILER_LOCATION "${CMAKE_CUDA_COMPILER}" PATH)
+
+# test to see if the d compiler is nvcc
+SET(CMAKE_CUDA_COMPILER_IS_NVCC_RUN 1)
+IF("${CMAKE_CUDA_COMPILER}" MATCHES ".*nvcc.*" )
+ SET(CMAKE_CUDA_COMPILER_IS_NVCC_RUN 1)
+ FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+ "Determining if the CUDA compiler is NVCC succeeded with "
+ "the following output:\n${CMAKE_CUDA_COMPILER}\n\n")
+ENDIF("${CMAKE_CUDA_COMPILER}" MATCHES ".*nvcc.*" )
+
+# configure variables set in this file for fast reload later on
+IF(EXISTS ${CMAKE_SOURCE_DIR}/cmake/CMakeCUDACompiler.cmake.in)
+ CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/CMakeCUDACompiler.cmake.in
+ "${CMAKE_PLATFORM_ROOT_BIN}/CMakeCUDACompiler.cmake" IMMEDIATE)
+ELSE(EXISTS ${CMAKE_SOURCE_DIR}/cmake/CMakeCUDACompiler.cmake.in)
+ CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeCUDACompiler.cmake.in
+ "${CMAKE_PLATFORM_ROOT_BIN}/CMakeCUDACompiler.cmake" IMMEDIATE)
+ENDIF(EXISTS ${CMAKE_SOURCE_DIR}/cmake/CMakeCUDACompiler.cmake.in)
+
+SET(CMAKE_CUDA_COMPILER_ENV_VAR "CUDAC")
@@ -0,0 +1,40 @@
+# Modified from CMakeTestCUDACompiler.cmake
+
+# This file is used by EnableLanguage in cmGlobalGenerator to
+# determine that that selected CUDA compiler can actually compile
+# and link the most basic of programs. If not, a fatal error
+# is set and cmake stops processing commands and will not generate
+# any makefiles or projects.
+IF(NOT CMAKE_CUDA_COMPILER_WORKS)
+ MESSAGE(STATUS "Check for working CUDA compiler: ${CMAKE_CUDA_COMPILER}")
+ FILE(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCUDACompiler.cu
+ "#ifndef __cplusplus\n"
+ "# error \"The CMAKE_CUDA_COMPILER is not a C++ compiler\"\n"
+ "#endif\n"
+ "int main(int argc, char* argv[])\n"
+ "{ return argc-1;}\n")
+ TRY_COMPILE(CMAKE_CUDA_COMPILER_WORKS ${CMAKE_BINARY_DIR}
+ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCUDACompiler.cu
+ OUTPUT_VARIABLE OUTPUT)
+ SET(CUDA_TEST_WAS_RUN 1)
+ENDIF(NOT CMAKE_CUDA_COMPILER_WORKS)
+
+IF(NOT CMAKE_CUDA_COMPILER_WORKS)
+ MESSAGE(STATUS "Check for working CUDA compiler: ${CMAKE_CUDA_COMPILER} -- broken")
+ FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Determining if the CUDA compiler works failed with "
+ "the following output:\n${OUTPUT}\n\n")
+ MESSAGE(FATAL_ERROR "The CUDA compiler \"${CMAKE_CUDA_COMPILER}\" "
+ "is not able to compile a simple test program.\nIt fails "
+ "with the following output:\n ${OUTPUT}\n\n"
+ "CMake will not be able to correctly generate this project.")
+ELSE(NOT CMAKE_CUDA_COMPILER_WORKS)
+ IF(CUDA_TEST_WAS_RUN)
+ MESSAGE(STATUS "Check for working CUDA compiler: ${CMAKE_CUDA_COMPILER} -- works")
+ FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+ "Determining if the CUDA compiler works passed with "
+ "the following output:\n${OUTPUT}\n\n")
+ ENDIF(CUDA_TEST_WAS_RUN)
+ SET(CMAKE_CUDA_COMPILER_WORKS 1 CACHE INTERNAL "")
+ENDIF(NOT CMAKE_CUDA_COMPILER_WORKS)
+
Oops, something went wrong.

0 comments on commit f0bb20a

Please sign in to comment.