diff options
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/CMakeGenericSystem.cmake | 102 | ||||
-rw-r--r-- | Modules/FindCUDA.cmake | 25 |
2 files changed, 111 insertions, 16 deletions
diff --git a/Modules/CMakeGenericSystem.cmake b/Modules/CMakeGenericSystem.cmake index 7d2d8cd..b5d3072 100644 --- a/Modules/CMakeGenericSystem.cmake +++ b/Modules/CMakeGenericSystem.cmake @@ -52,6 +52,94 @@ IF(CMAKE_GENERATOR MATCHES "Makefiles") ENDIF(DEFINED CMAKE_RULE_MESSAGES) ENDIF(CMAKE_GENERATOR MATCHES "Makefiles") + +# GetDefaultWindowsPrefixBase +# +# Compute the base directory for CMAKE_INSTALL_PREFIX based on: +# - is this 32-bit or 64-bit Windows +# - is this 32-bit or 64-bit CMake running +# - what architecture targets will be built +# +function(GetDefaultWindowsPrefixBase var) + + # Try to guess what architecture targets will end up being built as, + # even if CMAKE_SIZEOF_VOID_P is not computed yet... We need to know + # the architecture of the targets being built to choose the right + # default value for CMAKE_INSTALL_PREFIX. + # + if("${CMAKE_GENERATOR}" MATCHES "Win64") + set(arch_hint "x64") + elseif("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8") + set(arch_hint "x64") + elseif("$ENV{LIB}" MATCHES "(amd64|ia64)") + set(arch_hint "x64") + endif() + + if(NOT arch_hint) + set(arch_hint "x86") + endif() + + # default env in a 64-bit app on Win64: + # ProgramFiles=C:\Program Files + # ProgramFiles(x86)=C:\Program Files (x86) + # ProgramW6432=C:\Program Files + # + # default env in a 32-bit app on Win64: + # ProgramFiles=C:\Program Files (x86) + # ProgramFiles(x86)=C:\Program Files (x86) + # ProgramW6432=C:\Program Files + # + # default env in a 32-bit app on Win32: + # ProgramFiles=C:\Program Files + # ProgramFiles(x86) NOT DEFINED + # ProgramW6432 NOT DEFINED + + # By default, use the ProgramFiles env var as the base value of + # CMAKE_INSTALL_PREFIX: + # + set(_PREFIX_ENV_VAR "ProgramFiles") + + if ("$ENV{ProgramW6432}" STREQUAL "") + # running on 32-bit Windows + # must be a 32-bit CMake, too... + #message("guess: this is a 32-bit CMake running on 32-bit Windows") + else() + # running on 64-bit Windows + if ("$ENV{ProgramW6432}" STREQUAL "$ENV{ProgramFiles}") + # 64-bit CMake + #message("guess: this is a 64-bit CMake running on 64-bit Windows") + if(NOT "${arch_hint}" STREQUAL "x64") + # building 32-bit targets + set(_PREFIX_ENV_VAR "ProgramFiles(x86)") + endif() + else() + # 32-bit CMake + #message("guess: this is a 32-bit CMake running on 64-bit Windows") + if("${arch_hint}" STREQUAL "x64") + # building 64-bit targets + set(_PREFIX_ENV_VAR "ProgramW6432") + endif() + endif() + endif() + + #if("${arch_hint}" STREQUAL "x64") + # message("guess: you are building a 64-bit app") + #else() + # message("guess: you are building a 32-bit app") + #endif() + + if(NOT "$ENV{${_PREFIX_ENV_VAR}}" STREQUAL "") + file(TO_CMAKE_PATH "$ENV{${_PREFIX_ENV_VAR}}" _base) + elseif(NOT "$ENV{SystemDrive}" STREQUAL "") + set(_base "$ENV{SystemDrive}/Program Files") + else() + set(_base "C:/Program Files") + endif() + + set(${var} "${_base}" PARENT_SCOPE) +endfunction() + + # Set a variable to indicate whether the value of CMAKE_INSTALL_PREFIX # was initialized by the block below. This is useful for user # projects to change the default prefix while still allowing the @@ -65,23 +153,11 @@ IF(CMAKE_HOST_UNIX) SET(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Install path prefix, prepended onto install directories.") ELSE(CMAKE_HOST_UNIX) - IF("$ENV{ProgramFiles}" MATCHES "^$") - IF("$ENV{SystemDrive}" MATCHES "^$") - SET(CMAKE_GENERIC_PROGRAM_FILES "C:/Program Files") - ELSE("$ENV{SystemDrive}" MATCHES "^$") - SET(CMAKE_GENERIC_PROGRAM_FILES "$ENV{SystemDrive}/Program Files") - ENDIF("$ENV{SystemDrive}" MATCHES "^$") - ELSE("$ENV{ProgramFiles}" MATCHES "^$") - SET(CMAKE_GENERIC_PROGRAM_FILES "$ENV{ProgramFiles}") - ENDIF("$ENV{ProgramFiles}" MATCHES "^$") + GetDefaultWindowsPrefixBase(CMAKE_GENERIC_PROGRAM_FILES) SET(CMAKE_INSTALL_PREFIX "${CMAKE_GENERIC_PROGRAM_FILES}/${PROJECT_NAME}" CACHE PATH "Install path prefix, prepended onto install directories.") SET(CMAKE_GENERIC_PROGRAM_FILES) - - # Make sure the prefix uses forward slashes. - STRING(REGEX REPLACE "\\\\" "/" - CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") ENDIF(CMAKE_HOST_UNIX) MARK_AS_ADVANCED( diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index d9b9d54..dad5709 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -514,11 +514,19 @@ set (CUDA_INCLUDE_DIRS ${CUDA_TOOLKIT_INCLUDE}) macro(FIND_LIBRARY_LOCAL_FIRST _var _names _doc) if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(_cuda_64bit_lib_dir "${CUDA_TOOLKIT_ROOT_DIR}/lib64") + # CUDA 3.2+ on Windows moved the library directoryies, so we need the new + # and old paths. + set(_cuda_64bit_lib_dir + "${CUDA_TOOLKIT_ROOT_DIR}/lib/x64" + "${CUDA_TOOLKIT_ROOT_DIR}/lib64" + ) endif() + # CUDA 3.2+ on Windows moved the library directories, so we need to new + # (lib/Win32) and the old path (lib). find_library(${_var} NAMES ${_names} PATHS ${_cuda_64bit_lib_dir} + "${CUDA_TOOLKIT_ROOT_DIR}/lib/Win32" "${CUDA_TOOLKIT_ROOT_DIR}/lib" ENV CUDA_LIB_PATH DOC ${_doc} @@ -578,9 +586,20 @@ macro(FIND_CUDA_HELPER_LIBS _name) mark_as_advanced(CUDA_${_name}_LIBRARY) endmacro(FIND_CUDA_HELPER_LIBS) +####################### +# Disable emulation for v3.1 onward +if(CUDA_VERSION VERSION_GREATER "3.0") + if(CUDA_BUILD_EMULATION) + message(FATAL_ERROR "CUDA_BUILD_EMULATION is not supported in version 3.1 and onwards. You must disable it to proceed. You have version ${CUDA_VERSION}.") + endif() +endif() + # Search for cufft and cublas libraries. -find_cuda_helper_libs(cufftemu) -find_cuda_helper_libs(cublasemu) +if(CUDA_VERSION VERSION_LESS "3.1") + # Emulation libraries aren't available in version 3.1 onward. + find_cuda_helper_libs(cufftemu) + find_cuda_helper_libs(cublasemu) +endif() find_cuda_helper_libs(cufft) find_cuda_helper_libs(cublas) |