summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Modules/FindCUDA.cmake85
-rw-r--r--Source/cmTarget.cxx70
-rw-r--r--Source/cmTarget.h7
-rw-r--r--Source/kwsys/kwsysDateStamp.cmake2
4 files changed, 103 insertions, 61 deletions
diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake
index aad4f21..18f7442 100644
--- a/Modules/FindCUDA.cmake
+++ b/Modules/FindCUDA.cmake
@@ -266,17 +266,17 @@ macro(CUDA_FIND_HELPER_FILE _name _extension)
# 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")
+ set(CUDA_${_name} "${CMAKE_CURRENT_LIST_DIR}/FindCUDA/${_full_name}")
+ if(NOT EXISTS "${CUDA_${_name}}")
+ set(error_message "${_full_name} not found in ${CMAKE_CURRENT_LIST_DIR}/FindCUDA")
if(CUDA_FIND_REQUIRED)
message(FATAL_ERROR "${error_message}")
- else(CUDA_FIND_REQUIRED)
+ else()
if(NOT CUDA_FIND_QUIETLY)
message(STATUS "${error_message}")
- endif(NOT CUDA_FIND_QUIETLY)
- endif(CUDA_FIND_REQUIRED)
- endif(NOT CUDA_${_name})
+ endif()
+ endif()
+ endif()
# 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)
@@ -320,9 +320,9 @@ macro(CUDA_INCLUDE_NVCC_DEPENDENCIES dependency_file)
# message("CUDA_NVCC_DEPEND NOT set")
# endif()
if(CUDA_NVCC_DEPEND)
- #message("CUDA_NVCC_DEPEND true")
+ #message("CUDA_NVCC_DEPEND found")
foreach(f ${CUDA_NVCC_DEPEND})
- #message("searching for ${f}")
+ # message("searching for ${f}")
if(NOT EXISTS ${f})
#message("file ${f} not found")
set(CUDA_NVCC_DEPEND_REGENERATE TRUE)
@@ -417,13 +417,14 @@ endforeach()
# if they have then clear the cache variables, so that will be detected again.
if(NOT "${CUDA_TOOLKIT_ROOT_DIR}" STREQUAL "${CUDA_TOOLKIT_ROOT_DIR_INTERNAL}")
unset(CUDA_NVCC_EXECUTABLE CACHE)
- unset(CUDA_VERSION CACHE)
unset(CUDA_TOOLKIT_INCLUDE CACHE)
unset(CUDA_CUDART_LIBRARY CACHE)
+ # Make sure you run this before you unset CUDA_VERSION.
if(CUDA_VERSION VERSION_EQUAL "3.0")
# This only existed in the 3.0 version of the CUDA toolkit
unset(CUDA_CUDARTEMU_LIBRARY CACHE)
endif()
+ unset(CUDA_VERSION CACHE)
unset(CUDA_CUDA_LIBRARY CACHE)
unset(CUDA_cublas_LIBRARY CACHE)
unset(CUDA_cublasemu_LIBRARY CACHE)
@@ -814,6 +815,43 @@ function(CUDA_BUILD_SHARED_LIBRARY shared_flag)
endfunction()
##############################################################################
+# Helper to avoid clashes of files with the same basename but different paths.
+# This doesn't attempt to do exactly what CMake internals do, which is to only
+# add this path when there is a conflict, since by the time a second collision
+# in names is detected it's already too late to fix the first one. For
+# consistency sake the relative path will be added to all files.
+function(CUDA_COMPUTE_BUILD_PATH path build_path)
+ #message("CUDA_COMPUTE_BUILD_PATH([${path}] ${build_path})")
+ # Only deal with CMake style paths from here on out
+ file(TO_CMAKE_PATH "${path}" bpath)
+ if (IS_ABSOLUTE "${bpath}")
+ # Absolute paths are generally unnessary, especially if something like
+ # FILE(GLOB_RECURSE) is used to pick up the files.
+ file(RELATIVE_PATH bpath "${CMAKE_CURRENT_SOURCE_DIR}" "${bpath}")
+ endif()
+
+ # This recipie is from cmLocalGenerator::CreateSafeUniqueObjectFileName in the
+ # CMake source.
+
+ # Remove leading /
+ string(REGEX REPLACE "^[/]+" "" bpath "${bpath}")
+ # Avoid absolute paths by removing ':'
+ string(REPLACE ":" "_" bpath "${bpath}")
+ # Avoid relative paths that go up the tree
+ string(REPLACE "../" "__/" bpath "${bpath}")
+ # Avoid spaces
+ string(REPLACE " " "_" bpath "${bpath}")
+
+ # Strip off the filename. I wait until here to do it, since removin the
+ # basename can make a path that looked like path/../basename turn into
+ # path/.. (notice the trailing slash).
+ get_filename_component(bpath "${bpath}" PATH)
+
+ set(${build_path} "${bpath}" PARENT_SCOPE)
+ #message("${build_path} = ${bpath}")
+endfunction()
+
+##############################################################################
# This helper macro populates the following variables and setups up custom
# commands and targets to invoke the nvcc compiler to generate C or PTX source
# dependent upon the format parameter. The compiler is invoked once with -M
@@ -982,13 +1020,6 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files)
list(APPEND nvcc_flags "-D${cuda_target}_EXPORTS")
endif()
- # Determine output directory
- if(CUDA_GENERATED_OUTPUT_DIR)
- set(cuda_compile_output_dir "${CUDA_GENERATED_OUTPUT_DIR}")
- else()
- set(cuda_compile_output_dir "${CMAKE_CURRENT_BINARY_DIR}")
- endif()
-
# Reset the output variable
set(_cuda_wrap_generated_files "")
@@ -999,6 +1030,19 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files)
get_source_file_property(_is_header ${file} HEADER_FILE_ONLY)
if(${file} MATCHES ".*\\.cu$" AND NOT _is_header)
+ # Determine output directory
+ cuda_compute_build_path("${file}" cuda_build_path)
+ set(cuda_compile_intermediate_directory "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${cuda_target}.dir/${cuda_build_path}")
+ if(CUDA_GENERATED_OUTPUT_DIR)
+ set(cuda_compile_output_dir "${CUDA_GENERATED_OUTPUT_DIR}")
+ else()
+ if ( compile_to_ptx )
+ set(cuda_compile_output_dir "${CMAKE_CURRENT_BINARY_DIR}")
+ else()
+ set(cuda_compile_output_dir "${cuda_compile_intermediate_directory}")
+ endif()
+ endif()
+
# Add a custom target to generate a c or ptx file. ######################
get_filename_component( basename ${file} NAME )
@@ -1018,10 +1062,10 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files)
# argument, so that the ${CMAKE_CFG_INTDIR} gets expanded at run time
# instead of configure time.
set(generated_file "${generated_file_path}/${generated_file_basename}")
- set(cmake_dependency_file "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${generated_file_basename}.depend")
- set(NVCC_generated_dependency_file "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${generated_file_basename}.NVCC-depend")
+ set(cmake_dependency_file "${cuda_compile_intermediate_directory}/${generated_file_basename}.depend")
+ set(NVCC_generated_dependency_file "${cuda_compile_intermediate_directory}/${generated_file_basename}.NVCC-depend")
set(generated_cubin_file "${generated_file_path}/${generated_file_basename}.cubin.txt")
- set(custom_target_script "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${generated_file_basename}.cmake")
+ set(custom_target_script "${cuda_compile_intermediate_directory}/${generated_file_basename}.cmake")
# Setup properties for obj files:
if( NOT compile_to_ptx )
@@ -1101,6 +1145,7 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files)
-D "generated_file:STRING=${generated_file}"
-D "generated_cubin_file:STRING=${generated_cubin_file}"
-P "${custom_target_script}"
+ WORKING_DIRECTORY "${cuda_compile_intermediate_directory}"
COMMENT "${cuda_build_comment_string}"
)
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 276c5e0..fc3c1c9 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -132,6 +132,7 @@ cmTarget::cmTarget()
this->LinkLibrariesAnalyzed = false;
this->HaveInstallRule = false;
this->DLLPlatform = false;
+ this->IsApple = false;
this->IsImportedTarget = false;
}
@@ -1218,6 +1219,9 @@ void cmTarget::SetMakefile(cmMakefile* mf)
this->Makefile->IsOn("CYGWIN") ||
this->Makefile->IsOn("MINGW"));
+ // Check whether we are targeting an Apple platform.
+ this->IsApple = this->Makefile->IsOn("APPLE");
+
// Setup default property values.
this->SetPropertyDefault("INSTALL_NAME_DIR", "");
this->SetPropertyDefault("INSTALL_RPATH", "");
@@ -3360,7 +3364,11 @@ void cmTarget::GetLibraryNames(std::string& name,
// the library version as the soversion.
soversion = version;
}
- bool isApple = this->Makefile->IsOn("APPLE");
+ if(!version && soversion)
+ {
+ // Use the soversion as the library version.
+ version = soversion;
+ }
// Get the components of the library name.
std::string prefix;
@@ -3372,47 +3380,12 @@ void cmTarget::GetLibraryNames(std::string& name,
name = prefix+base+suffix;
// The library's soname.
- if(isApple)
- {
- soName = prefix+base;
- }
- else
- {
- soName = name;
- }
- if(soversion)
- {
- soName += ".";
- soName += soversion;
- }
- if(isApple)
- {
- soName += suffix;
- }
+ this->ComputeVersionedName(soName, prefix, base, suffix,
+ name, soversion);
// The library's real name on disk.
- if(isApple)
- {
- realName = prefix+base;
- }
- else
- {
- realName = name;
- }
- if(version)
- {
- realName += ".";
- realName += version;
- }
- else if(soversion)
- {
- realName += ".";
- realName += soversion;
- }
- if(isApple)
- {
- realName += suffix;
- }
+ this->ComputeVersionedName(realName, prefix, base, suffix,
+ name, version);
// The import library name.
if(this->GetType() == cmTarget::SHARED_LIBRARY ||
@@ -3430,6 +3403,23 @@ void cmTarget::GetLibraryNames(std::string& name,
}
//----------------------------------------------------------------------------
+void cmTarget::ComputeVersionedName(std::string& vName,
+ std::string const& prefix,
+ std::string const& base,
+ std::string const& suffix,
+ std::string const& name,
+ const char* version)
+{
+ vName = this->IsApple? (prefix+base) : name;
+ if(version)
+ {
+ vName += ".";
+ vName += version;
+ }
+ vName += this->IsApple? suffix : std::string();
+}
+
+//----------------------------------------------------------------------------
void cmTarget::GetExecutableNames(std::string& name,
std::string& realName,
std::string& impName,
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 09fee6c..59f0184 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -565,6 +565,7 @@ private:
cmPropertyMap Properties;
LinkLibraryVectorType OriginalLinkLibraries;
bool DLLPlatform;
+ bool IsApple;
bool IsImportedTarget;
// Cache target output paths for each configuration.
@@ -603,6 +604,12 @@ private:
cmTargetInternalPointer Internal;
void ConstructSourceFileFlags();
+ void ComputeVersionedName(std::string& vName,
+ std::string const& prefix,
+ std::string const& base,
+ std::string const& suffix,
+ std::string const& name,
+ const char* version);
};
typedef std::map<cmStdString,cmTarget> cmTargets;
diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake
index 280d3f3..625cc6e 100644
--- a/Source/kwsys/kwsysDateStamp.cmake
+++ b/Source/kwsys/kwsysDateStamp.cmake
@@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011)
SET(KWSYS_DATE_STAMP_MONTH 12)
# KWSys version date day component. Format is DD.
-SET(KWSYS_DATE_STAMP_DAY 06)
+SET(KWSYS_DATE_STAMP_DAY 07)