diff options
64 files changed, 639 insertions, 186 deletions
diff --git a/Modules/CMakeDetermineSystem.cmake b/Modules/CMakeDetermineSystem.cmake index 20c1541..3a95d2a 100644 --- a/Modules/CMakeDetermineSystem.cmake +++ b/Modules/CMakeDetermineSystem.cmake @@ -73,7 +73,7 @@ if(CMAKE_HOST_UNIX) else() if(CMAKE_HOST_WIN32) set (CMAKE_HOST_SYSTEM_NAME "Windows") - if (ENV{PROCESSOR_ARCHITEW6432}) + if (DEFINED ENV{PROCESSOR_ARCHITEW6432}) set (CMAKE_HOST_SYSTEM_PROCESSOR "$ENV{PROCESSOR_ARCHITEW6432}") else() set (CMAKE_HOST_SYSTEM_PROCESSOR "$ENV{PROCESSOR_ARCHITECTURE}") diff --git a/Modules/CTestTargets.cmake b/Modules/CTestTargets.cmake index fd4bd80..5b6e062 100644 --- a/Modules/CTestTargets.cmake +++ b/Modules/CTestTargets.cmake @@ -16,6 +16,10 @@ if(NOT RUN_FROM_CTEST_OR_DART) message(FATAL_ERROR "Do not incldue CTestTargets.cmake directly") endif() +if(NOT PROJECT_BINARY_DIR) + message(FATAL_ERROR "Do not include(CTest) before calling project().") +endif() + # make directories in the binary tree file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/Testing/Temporary) get_filename_component(CMAKE_HOST_PATH ${CMAKE_COMMAND} PATH) diff --git a/Modules/ExternalData.cmake b/Modules/ExternalData.cmake index 9d84f8d..187f408 100644 --- a/Modules/ExternalData.cmake +++ b/Modules/ExternalData.cmake @@ -156,7 +156,8 @@ # License text for the above reference.) function(ExternalData_add_test target) - ExternalData_expand_arguments("${target}" testArgs ${ARGN}) + # Expand all arguments as a single string to preserve escaped semicolons. + ExternalData_expand_arguments("${target}" testArgs "${ARGN}") add_test(${testArgs}) endfunction() @@ -234,13 +235,17 @@ endfunction() function(ExternalData_expand_arguments target outArgsVar) # Replace DATA{} references with real arguments. - set(data_regex "DATA{([^{}\r\n]*)}") + set(data_regex "DATA{([^;{}\r\n]*)}") set(other_regex "([^D]|D[^A]|DA[^T]|DAT[^A]|DATA[^{])+|.") set(outArgs "") + # This list expansion un-escapes semicolons in list element values so we + # must re-escape them below anywhere a new list expansion will occur. foreach(arg IN LISTS ARGN) if("x${arg}" MATCHES "${data_regex}") + # Re-escape in-value semicolons before expansion in foreach below. + string(REPLACE ";" "\\;" tmp "${arg}") # Split argument into DATA{}-pieces and other pieces. - string(REGEX MATCHALL "${data_regex}|${other_regex}" pieces "${arg}") + string(REGEX MATCHALL "${data_regex}|${other_regex}" pieces "${tmp}") # Compose output argument with DATA{}-pieces replaced. set(outArg "") foreach(piece IN LISTS pieces) @@ -254,11 +259,13 @@ function(ExternalData_expand_arguments target outArgsVar) set(outArg "${outArg}${piece}") endif() endforeach() - list(APPEND outArgs "${outArg}") else() # No replacements needed in this argument. - list(APPEND outArgs "${arg}") + set(outArg "${arg}") endif() + # Re-escape in-value semicolons in resulting list. + string(REPLACE ";" "\\;" outArg "${outArg}") + list(APPEND outArgs "${outArg}") endforeach() set("${outArgsVar}" "${outArgs}" PARENT_SCOPE) endfunction() diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index 5a834b1..61d6ea7 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -91,6 +91,13 @@ # CUDA_ADD_LIBRARY, CUDA_ADD_EXECUTABLE, or CUDA_WRAP_SRCS. Flags used for # shared library compilation are not affected by this flag. # +# CUDA_SEPARABLE_COMPILATION (Default OFF) +# -- If set this will enable separable compilation for all CUDA runtime object +# files. If used outside of CUDA_ADD_EXECUTABLE and CUDA_ADD_LIBRARY +# (e.g. calling CUDA_WRAP_SRCS directly), +# CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME and +# CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS should be called. +# # 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 @@ -137,11 +144,36 @@ # CUDA_COMPILE_PTX( generated_files file0 file1 ... [OPTIONS ...] ) # -- Returns a list of PTX files generated from the input source files. # +# CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME( output_file_var +# cuda_target +# object_files ) +# -- Compute the name of the intermediate link file used for separable +# compilation. This file name is typically passed into +# CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS. output_file_var is produced +# based on cuda_target the list of objects files that need separable +# compilation as specified by object_files. If the object_files list is +# empty, then output_file_var will be empty. This function is called +# automatically for CUDA_ADD_LIBRARY and CUDA_ADD_EXECUTABLE. Note that +# this is a function and not a macro. +# # 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_LINK_SEPARABLE_COMPILATION_OBJECTS( output_file_var cuda_target +# nvcc_flags object_files) +# +# -- Generates the link object required by separable compilation from the given +# object files. This is called automatically for CUDA_ADD_EXECUTABLE and +# CUDA_ADD_LIBRARY, but can be called manually when using CUDA_WRAP_SRCS +# directly. When called from CUDA_ADD_LIBRARY or CUDA_ADD_EXECUTABLE the +# nvcc_flags passed in are the same as the flags passed in via the OPTIONS +# argument. The only nvcc flag added automatically is the bitness flag as +# specified by CUDA_64_BIT_DEVICE_CODE. Note that this is a function +# instead of a macro. +# # CUDA_WRAP_SRCS ( cuda_target format generated_files file0 file1 ... # [STATIC | SHARED | MODULE] [OPTIONS ...] ) # -- This is where all the magic happens. CUDA_ADD_EXECUTABLE, @@ -223,6 +255,8 @@ # CUDA_CUBLAS_LIBRARIES -- Device or emulation library for the Cuda BLAS # implementation (alterative to: # CUDA_ADD_CUBLAS_TO_TARGET macro). +# CUDA_cupti_LIBRARY -- CUDA Profiling Tools Interface library. +# Only available for CUDA version 4.0+. # CUDA_curand_LIBRARY -- CUDA Random Number Generation library. # Only available for CUDA version 3.2+. # CUDA_cusparse_LIBRARY -- CUDA Sparse Matrix library. @@ -406,6 +440,9 @@ endif() # Propagate the host flags to the host compiler via -Xcompiler option(CUDA_PROPAGATE_HOST_FLAGS "Propage C/CXX_FLAGS and friends to the host compiler via -Xcompile" ON) +# Enable CUDA_SEPARABLE_COMPILATION +option(CUDA_SEPARABLE_COMPILATION "Compile CUDA objects with separable compilation enabled. Requires CUDA 5.0+" OFF) + # Specifies whether the commands used when compiling the .cu file will be printed out. option(CUDA_VERBOSE_BUILD "Print out the commands run while compiling the CUDA source file. With the Makefile generator this defaults to VERBOSE variable specified on the command line, but can be forced on with this option." OFF) @@ -451,6 +488,7 @@ if(NOT "${CUDA_TOOLKIT_ROOT_DIR}" STREQUAL "${CUDA_TOOLKIT_ROOT_DIR_INTERNAL}") endif() unset(CUDA_VERSION CACHE) unset(CUDA_CUDA_LIBRARY CACHE) + unset(CUDA_cupti_LIBRARY CACHE) unset(CUDA_cublas_LIBRARY CACHE) unset(CUDA_cublasemu_LIBRARY CACHE) unset(CUDA_cufft_LIBRARY CACHE) @@ -551,11 +589,11 @@ mark_as_advanced(CUDA_TOOLKIT_INCLUDE) set (CUDA_NVCC_INCLUDE_ARGS_USER "") set (CUDA_INCLUDE_DIRS ${CUDA_TOOLKIT_INCLUDE}) -macro(FIND_LIBRARY_LOCAL_FIRST _var _names _doc) +macro(cuda_find_library_local_first_with_path_ext _var _names _doc _path_ext ) if(CMAKE_SIZEOF_VOID_P EQUAL 8) # CUDA 3.2+ on Windows moved the library directories, so we need the new # and old paths. - set(_cuda_64bit_lib_dir "lib/x64" "lib64" ) + set(_cuda_64bit_lib_dir "${_path_ext}lib/x64" "${_path_ext}lib64" "${_path_ext}libx64" ) endif() # CUDA 3.2+ on Windows moved the library directories, so we need to new # (lib/Win32) and the old path (lib). @@ -564,7 +602,7 @@ macro(FIND_LIBRARY_LOCAL_FIRST _var _names _doc) PATHS "${CUDA_TOOLKIT_ROOT_DIR}" ENV CUDA_PATH ENV CUDA_LIB_PATH - PATH_SUFFIXES ${_cuda_64bit_lib_dir} "lib/Win32" "lib" + PATH_SUFFIXES ${_cuda_64bit_lib_dir} "${_path_ext}lib/Win32" "${_path_ext}lib" "${_path_ext}libWin32" DOC ${_doc} NO_DEFAULT_PATH ) @@ -572,15 +610,31 @@ macro(FIND_LIBRARY_LOCAL_FIRST _var _names _doc) find_library(${_var} NAMES ${_names} DOC ${_doc}) endmacro() +macro(cuda_find_library_local_first _var _names _doc) + cuda_find_library_local_first_with_path_ext( "${_var}" "${_names}" "${_doc}" "" ) +endmacro() + +macro(find_library_local_first _var _names _doc ) + cuda_find_library_local_first( "${_var}" "${_names}" "${_doc}" "" ) +endmacro() + + # CUDA_LIBRARIES -find_library_local_first(CUDA_CUDART_LIBRARY cudart "\"cudart\" library") +cuda_find_library_local_first(CUDA_CUDART_LIBRARY cudart "\"cudart\" library") if(CUDA_VERSION VERSION_EQUAL "3.0") # The cudartemu library only existed for the 3.0 version of CUDA. - find_library_local_first(CUDA_CUDARTEMU_LIBRARY cudartemu "\"cudartemu\" library") + cuda_find_library_local_first(CUDA_CUDARTEMU_LIBRARY cudartemu "\"cudartemu\" library") mark_as_advanced( CUDA_CUDARTEMU_LIBRARY ) endif() + +# CUPTI library showed up in cuda toolkit 4.0 +if(NOT CUDA_VERSION VERSION_LESS "4.0") + cuda_find_library_local_first_with_path_ext(CUDA_cupti_LIBRARY cupti "\"cupti\" library" "extras/CUPTI/") + mark_as_advanced(CUDA_cupti_LIBRARY) +endif() + # If we are using emulation mode and we found the cudartemu library then use # that one instead of cudart. if(CUDA_BUILD_EMULATION AND CUDA_CUDARTEMU_LIBRARY) @@ -603,12 +657,7 @@ endif() # 1.1 toolkit on linux doesn't appear to have a separate library on # some platforms. -find_library_local_first(CUDA_CUDA_LIBRARY cuda "\"cuda\" library (older versions only).") - -# Add cuda library to the link line only if it is found. -if (CUDA_CUDA_LIBRARY) - set(CUDA_LIBRARIES ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY}) -endif() +cuda_find_library_local_first(CUDA_CUDA_LIBRARY cuda "\"cuda\" library (older versions only).") mark_as_advanced( CUDA_CUDA_LIBRARY @@ -618,7 +667,7 @@ mark_as_advanced( ####################### # Look for some of the toolkit helper libraries macro(FIND_CUDA_HELPER_LIBS _name) - find_library_local_first(CUDA_${_name}_LIBRARY ${_name} "\"${_name}\" library") + cuda_find_library_local_first(CUDA_${_name}_LIBRARY ${_name} "\"${_name}\" library") mark_as_advanced(CUDA_${_name}_LIBRARY) endmacro() @@ -913,6 +962,11 @@ endfunction() macro(CUDA_WRAP_SRCS cuda_target format generated_files) + # If CMake doesn't support separable compilation, complain + if(CUDA_SEPARABLE_COMPILATION AND CMAKE_VERSION VERSION_LESS "2.8.10.1") + message(SEND_ERROR "CUDA_SEPARABLE_COMPILATION isn't supported for CMake versions less than 2.8.10.1") + endif() + # Set up all the command line flags here, so that they can be overridden on a per target basis. set(nvcc_flags "") @@ -950,6 +1004,8 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files) # $(VCInstallDir)/bin. if(CMAKE_GENERATOR MATCHES "Visual Studio") set(ccbin_flags -D "\"CCBIN:PATH=$(VCInstallDir)bin\"" ) + else() + set(ccbin_flags) endif() # Figure out which configure we will use and pass that in as an argument to @@ -1117,7 +1173,11 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files) else() set(generated_file_path "${cuda_compile_output_dir}/${CMAKE_CFG_INTDIR}") set(generated_file_basename "${cuda_target}_generated_${basename}${generated_extension}") - set(format_flag "-c") + if(CUDA_SEPARABLE_COMPILATION) + set(format_flag "-dc") + else() + set(format_flag "-c") + endif() endif() # Set all of our file names. Make sure that whatever filenames that have @@ -1146,6 +1206,10 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files) set(source_file "${CMAKE_CURRENT_SOURCE_DIR}/${file}") endif() + if( NOT compile_to_ptx AND CUDA_SEPARABLE_COMPILATION) + list(APPEND ${cuda_target}_SEPARABLE_COMPILATION_OBJECTS "${generated_file}") + endif() + # Bring in the dependencies. Creates a variable CUDA_NVCC_DEPEND ####### cuda_include_nvcc_dependencies(${cmake_dependency_file}) @@ -1244,6 +1308,85 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files) set(${generated_files} ${_cuda_wrap_generated_files}) endmacro() +function(_cuda_get_important_host_flags important_flags flag_string) + if(CMAKE_GENERATOR MATCHES "Visual Studio") + string(REGEX MATCHALL "/M[DT][d]?" flags ${flag_string}) + list(APPEND ${important_flags} ${flags}) + else() + string(REGEX MATCHALL "-fPIC" flags ${flag_string}) + list(APPEND ${important_flags} ${flags}) + endif() + set(${important_flags} ${${important_flags}} PARENT_SCOPE) +endfunction() + +############################################################################### +############################################################################### +# Separable Compilation Link +############################################################################### +############################################################################### + +# Compute the filename to be used by CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS +function(CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME output_file_var cuda_target object_files) + if (object_files) + set(generated_extension ${CMAKE_${CUDA_C_OR_CXX}_OUTPUT_EXTENSION}) + set(output_file "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${cuda_target}.dir/${CMAKE_CFG_INTDIR}/${cuda_target}_intermediate_link${generated_extension}") + else() + set(output_file) + endif() + + set(${output_file_var} "${output_file}" PARENT_SCOPE) +endfunction() + +# Setup the build rule for the separable compilation intermediate link file. +function(CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS output_file cuda_target options object_files) + if (object_files) + + if(NOT EXISTS "${output_file}") + # Some generators (e.g. makefiles) can't proceed to the link phase if all + # input files aren't available. This guarantees the file exists, so that + # linking can begin. + execute_process(COMMAND ${CMAKE_COMMAND} -E touch "${output_file}") + endif() + + set_source_files_properties("${output_file}" + PROPERTIES + EXTERNAL_OBJECT TRUE # This is an object file not to be compiled, but only + # be linked. + GENERATED TRUE # This file is generated during the build + ) + + # For now we are ignoring all the configuration specific flags. + set(nvcc_flags) + CUDA_PARSE_NVCC_OPTIONS(nvcc_flags ${options}) + if(CUDA_64_BIT_DEVICE_CODE) + list(APPEND nvcc_flags -m64) + else() + list(APPEND nvcc_flags -m32) + endif() + # If -ccbin, --compiler-bindir has been specified, don't do anything. Otherwise add it here. + list( FIND nvcc_flags "-ccbin" ccbin_found0 ) + list( FIND nvcc_flags "--compiler-bindir" ccbin_found1 ) + if( ccbin_found0 LESS 0 AND ccbin_found1 LESS 0 ) + list(APPEND nvcc_flags -ccbin "\"${CUDA_HOST_COMPILER}\"") + endif() + set(flags) + foreach(config ${CUDA_configuration_types}) + string(TOUPPER ${config} config_upper) + set(important_host_flags) + _cuda_get_important_host_flags(important_host_flags ${CMAKE_${CUDA_C_OR_CXX}_FLAGS_${config_upper}}) + foreach(f ${important_host_flags}) + list(APPEND flags $<$<CONFIG:${config}>:-Xcompiler> $<$<CONFIG:${config}>:${f}>) + endforeach() + endforeach() + file(RELATIVE_PATH output_file_relative_path "${CMAKE_BINARY_DIR}" "${output_file}") + add_custom_command( + TARGET ${cuda_target} + PRE_LINK + COMMAND ${CMAKE_COMMAND} -E echo "Building NVCC intermediate link file ${output_file_relative_path}" + COMMAND ${CUDA_NVCC_EXECUTABLE} ${nvcc_flags} ${flags} -dlink ${object_files} -o "${output_file}" + ) + endif() +endfunction() ############################################################################### ############################################################################### @@ -1262,12 +1405,22 @@ macro(CUDA_ADD_LIBRARY cuda_target) ${_cmake_options} ${_cuda_shared_flag} OPTIONS ${_options} ) + # Compute the file name of the intermedate link file used for separable + # compilation. + CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME(link_file ${cuda_target} "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") + # Add the library. add_library(${cuda_target} ${_cmake_options} ${_generated_files} ${_sources} + ${link_file} ) + # Add a link phase for the separable compilation if it has been enabled. If + # it has been enabled then the ${cuda_target}_SEPARABLE_COMPILATION_OBJECTS + # variable will have been defined. + CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS("${link_file}" ${cuda_target} "${_options}" "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") + target_link_libraries(${cuda_target} ${CUDA_LIBRARIES} ) @@ -1296,12 +1449,22 @@ macro(CUDA_ADD_EXECUTABLE cuda_target) # Create custom commands and targets for each file. CUDA_WRAP_SRCS( ${cuda_target} OBJ _generated_files ${_sources} OPTIONS ${_options} ) + # Compute the file name of the intermedate link file used for separable + # compilation. + CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME(link_file ${cuda_target} "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") + # Add the library. add_executable(${cuda_target} ${_cmake_options} ${_generated_files} ${_sources} + ${link_file} ) + # Add a link phase for the separable compilation if it has been enabled. If + # it has been enabled then the ${cuda_target}_SEPARABLE_COMPILATION_OBJECTS + # variable will have been defined. + CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS("${link_file}" ${cuda_target} "${_options}" "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") + target_link_libraries(${cuda_target} ${CUDA_LIBRARIES} ) diff --git a/Modules/FindImageMagick.cmake b/Modules/FindImageMagick.cmake index bf09616..4aaefb7 100644 --- a/Modules/FindImageMagick.cmake +++ b/Modules/FindImageMagick.cmake @@ -147,17 +147,17 @@ foreach(component ${ImageMagick_FIND_COMPONENTS} ) if(component STREQUAL "Magick++") FIND_IMAGEMAGICK_API(Magick++ Magick++.h - Magick++ CORE_RL_Magick++_ + Magick++ CORE_RL_Magick++_ Magick++-Q16 Magick++-Q8 ) list(APPEND ImageMagick_REQUIRED_VARS ImageMagick_Magick++_LIBRARY) elseif(component STREQUAL "MagickWand") FIND_IMAGEMAGICK_API(MagickWand wand/MagickWand.h - Wand MagickWand CORE_RL_wand_ + Wand MagickWand CORE_RL_wand_ MagickWand-Q16 MagickWand-Q8 ) list(APPEND ImageMagick_REQUIRED_VARS ImageMagick_MagickWand_LIBRARY) elseif(component STREQUAL "MagickCore") FIND_IMAGEMAGICK_API(MagickCore magick/MagickCore.h - Magick MagickCore CORE_RL_magick_ + Magick MagickCore CORE_RL_magick_ MagickCore-Q16 MagickCore-Q8 ) list(APPEND ImageMagick_REQUIRED_VARS ImageMagick_MagickCore_LIBRARY) else() diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index f25e121..1dd2782 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -509,54 +509,71 @@ function(_QT4_QUERY_QMAKE VAR RESULT) endif() endfunction() +function(_QT4_GET_VERSION_COMPONENTS VERSION RESULT_MAJOR RESULT_MINOR RESULT_PATCH) + string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" QT_VERSION_MAJOR "${QTVERSION}") + string(REGEX REPLACE "^[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" QT_VERSION_MINOR "${QTVERSION}") + string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" QT_VERSION_PATCH "${QTVERSION}") -set(QT4_INSTALLED_VERSION_TOO_OLD FALSE) + set(${RESULT_MAJOR} ${QT_VERSION_MAJOR} PARENT_SCOPE) + set(${RESULT_MINOR} ${QT_VERSION_MINOR} PARENT_SCOPE) + set(${RESULT_PATCH} ${QT_VERSION_PATCH} PARENT_SCOPE) +endfunction() -get_filename_component(qt_install_version "[HKEY_CURRENT_USER\\Software\\trolltech\\Versions;DefaultQtVersion]" NAME) -# check for qmake -# Debian uses qmake-qt4 -# macports' Qt uses qmake-mac -find_program(QT_QMAKE_EXECUTABLE NAMES qmake qmake4 qmake-qt4 qmake-mac - PATHS - ENV QTDIR - "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\${qt_install_version};InstallDir]" - PATH_SUFFIXES bin - DOC "The qmake executable for the Qt installation to use" -) - -# double check that it was a Qt4 qmake, if not, re-find with different names -if (QT_QMAKE_EXECUTABLE) - - if(QT_QMAKE_EXECUTABLE_LAST) - string(COMPARE NOTEQUAL "${QT_QMAKE_EXECUTABLE_LAST}" "${QT_QMAKE_EXECUTABLE}" QT_QMAKE_CHANGED) +function(_QT4_FIND_QMAKE QMAKE_NAMES QMAKE_RESULT VERSION_RESULT) + list(LENGTH QMAKE_NAMES QMAKE_NAMES_LEN) + if(${QMAKE_NAMES_LEN} EQUAL 0) + return() endif() + list(GET QMAKE_NAMES 0 QMAKE_NAME) - set(QT_QMAKE_EXECUTABLE_LAST "${QT_QMAKE_EXECUTABLE}" CACHE INTERNAL "" FORCE) + get_filename_component(qt_install_version "[HKEY_CURRENT_USER\\Software\\trolltech\\Versions;DefaultQtVersion]" NAME) + + find_program(QT_QMAKE_EXECUTABLE NAMES ${QMAKE_NAME} + PATHS + ENV QTDIR + "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\${qt_install_version};InstallDir]" + PATH_SUFFIXES bin + DOC "The qmake executable for the Qt installation to use" + ) + + set(major 0) + if (QT_QMAKE_EXECUTABLE) + _qt4_query_qmake(QT_VERSION QTVERSION) + _qt4_get_version_components("${QTVERSION}" major minor patch) + endif() - _qt4_query_qmake(QT_VERSION QTVERSION) + if (NOT QT_QMAKE_EXECUTABLE OR NOT "${major}" EQUAL 4) + set(curr_qmake "${QT_QMAKE_EXECUTABLE}") + set(curr_qt_version "${QTVERSION}") - # check for qt3 qmake and then try and find qmake4 or qmake-qt4 in the path - if(NOT QTVERSION) set(QT_QMAKE_EXECUTABLE NOTFOUND CACHE FILEPATH "" FORCE) - find_program(QT_QMAKE_EXECUTABLE NAMES qmake4 qmake-qt4 PATHS - "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/bin" - "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/bin" - $ENV{QTDIR}/bin - DOC "The qmake executable for the Qt installation to use" - ) - if(QT_QMAKE_EXECUTABLE) - _qt4_query_qmake(QT_VERSION QTVERSION) + list(REMOVE_AT QMAKE_NAMES 0) + _qt4_find_qmake("${QMAKE_NAMES}" QMAKE QTVERSION) + + _qt4_get_version_components("${QTVERSION}" major minor patch) + if (NOT ${major} EQUAL 4) + # Restore possibly found qmake and it's version; these are used later + # in error message if incorrect version is found + set(QT_QMAKE_EXECUTABLE "${curr_qmake}" CACHE FILEPATH "" FORCE) + set(QTVERSION "${curr_qt_version}") endif() + endif() -endif () + + set(${QMAKE_RESULT} "${QT_QMAKE_EXECUTABLE}" PARENT_SCOPE) + set(${VERSION_RESULT} "${QTVERSION}" PARENT_SCOPE) +endfunction() + + +set(QT4_INSTALLED_VERSION_TOO_OLD FALSE) + +set(_QT4_QMAKE_NAMES qmake qmake4 qmake-qt4 qmake-mac) +_qt4_find_qmake("${_QT4_QMAKE_NAMES}" QT_QMAKE_EXECUTABLE QTVERSION) if (QT_QMAKE_EXECUTABLE AND QTVERSION) - # set version variables - string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" QT_VERSION_MAJOR "${QTVERSION}") - string(REGEX REPLACE "^[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" QT_VERSION_MINOR "${QTVERSION}") - string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" QT_VERSION_PATCH "${QTVERSION}") + _qt4_get_version_components("${QTVERSION}" QT_VERSION_MAJOR QT_VERSION_MINOR QT_VERSION_PATCH) # ask qmake for the mkspecs directory # we do this first because QT_LIBINFIX might be set @@ -1330,7 +1347,7 @@ else() endif() -if (QT_VERSION_MAJOR GREATER 4) +if (NOT QT_VERSION_MAJOR EQUAL 4) set(VERSION_MSG "Found unsuitable Qt version \"${QTVERSION}\" from ${QT_QMAKE_EXECUTABLE}") set(QT4_FOUND FALSE) if(Qt4_FIND_REQUIRED) diff --git a/Modules/Platform/AIX-GNU.cmake b/Modules/Platform/AIX-GNU.cmake index a73a7a2..e5d9434 100644 --- a/Modules/Platform/AIX-GNU.cmake +++ b/Modules/Platform/AIX-GNU.cmake @@ -21,7 +21,7 @@ set(__AIX_COMPILER_GNU 1) macro(__aix_compiler_gnu lang) set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-Wl,-blibpath:") set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":") - set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS} -Wl,-G,-brtl,-bnoipath") + set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS} -Wl,-G,-bnoipath") set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-Wl,-brtl,-bnoipath,-bexpall") # +s, flag for exe link to use shared lib set(CMAKE_${lang}_USE_IMPLICIT_LINK_DIRECTORIES_IN_RUNTIME_PATH 1) endmacro() diff --git a/Modules/Platform/AIX-XL.cmake b/Modules/Platform/AIX-XL.cmake index 1f94152..abf3855 100644 --- a/Modules/Platform/AIX-XL.cmake +++ b/Modules/Platform/AIX-XL.cmake @@ -21,7 +21,7 @@ set(__AIX_COMPILER_XL 1) macro(__aix_compiler_xl lang) set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-Wl,-blibpath:") set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":") - set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-G -Wl,-brtl,-bnoipath") # -shared + set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-G -Wl,-bnoipath") # -shared set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-Wl,-brtl,-bnoipath,-bexpall") # +s, flag for exe link to use shared lib set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS " ") set(CMAKE_SHARED_MODULE_${lang}_FLAGS " ") diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 2e5cafd..6f3e6ef 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130309) +set(CMake_VERSION_TWEAK 20130313) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index 9f86ea2..62bfa91 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -432,11 +432,14 @@ int cmCPackNSISGenerator::InitializeInternal() int retVal = 1; bool resS = cmSystemTools::RunSingleCommand(nsisCmd.c_str(), &output, &retVal, 0, this->GeneratorVerbose, 0); - cmsys::RegularExpression versionRex("v([0-9]+.[0-9]+)"); - if ( !resS || retVal || !versionRex.find(output)) + cmsys::RegularExpression versionRexCVS("v(.*)\\.cvs"); + if ( !resS || retVal || + (!versionRex.find(output) && !versionRexCVS.find(output)) + ) { - std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); + const char* topDir = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); + std::string tmpFile = topDir ? topDir : "."; tmpFile += "/NSISOutput.log"; cmGeneratedFileStream ofs(tmpFile.c_str()); ofs << "# Run command: " << nsisCmd.c_str() << std::endl @@ -448,17 +451,26 @@ int cmCPackNSISGenerator::InitializeInternal() << "Please check " << tmpFile.c_str() << " for errors" << std::endl); return 0; } - double nsisVersion = atof(versionRex.match(1).c_str()); - double minNSISVersion = 2.09; - cmCPackLogger(cmCPackLog::LOG_DEBUG, "NSIS Version: " - << nsisVersion << std::endl); - if ( nsisVersion < minNSISVersion ) + if ( versionRex.find(output)) { - cmCPackLogger(cmCPackLog::LOG_ERROR, - "CPack requires NSIS Version 2.09 or greater. NSIS found on the system " - "was: " + double nsisVersion = atof(versionRex.match(1).c_str()); + double minNSISVersion = 2.09; + cmCPackLogger(cmCPackLog::LOG_DEBUG, "NSIS Version: " << nsisVersion << std::endl); - return 0; + if ( nsisVersion < minNSISVersion ) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "CPack requires NSIS Version 2.09 or greater. " + "NSIS found on the system was: " + << nsisVersion << std::endl); + return 0; + } + } + if ( versionRexCVS.find(output)) + { + // No version check for NSIS cvs build + cmCPackLogger(cmCPackLog::LOG_DEBUG, "NSIS Version: CVS " + << versionRexCVS.match(1).c_str() << std::endl); } this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM", nsisPath.c_str()); this->SetOptionIfNotSet("CPACK_NSIS_EXECUTABLES_DIRECTORY", "bin"); diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index 29daffd..1684fb2 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -27,6 +27,8 @@ if (Qt5Widgets_FOUND) set(QT_LIBRARIES ${Qt5Widgets_LIBRARIES}) # Remove this when the minimum version of Qt is 4.6. add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0) + + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}") else() set(QT_MIN_VERSION "4.4.0") find_package(Qt4 REQUIRED) diff --git a/Source/QtDialog/QCMakeCacheView.cxx b/Source/QtDialog/QCMakeCacheView.cxx index 1d21d42..031350b 100644 --- a/Source/QtDialog/QCMakeCacheView.cxx +++ b/Source/QtDialog/QCMakeCacheView.cxx @@ -490,7 +490,11 @@ QCMakePropertyList QCMakeCacheModel::properties() const } // go to the next in the tree - while(!idxs.isEmpty() && !idxs.last().sibling(idxs.last().row()+1, 0).isValid()) + while(!idxs.isEmpty() && ( +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 3) + (idxs.last().row()+1) >= rowCount(idxs.last().parent()) || +#endif + !idxs.last().sibling(idxs.last().row()+1, 0).isValid())) { idxs.removeLast(); } diff --git a/Source/cmAddSubDirectoryCommand.cxx b/Source/cmAddSubDirectoryCommand.cxx index 9efeda4..5b1c9c6 100644 --- a/Source/cmAddSubDirectoryCommand.cxx +++ b/Source/cmAddSubDirectoryCommand.cxx @@ -78,7 +78,7 @@ bool cmAddSubDirectoryCommand::InitialPass // No binary directory was specified. If the source directory is // not a subdirectory of the current directory then it is an // error. - if(!cmSystemTools::FindLastString(srcPath.c_str(), + if(!cmSystemTools::IsSubDirectory(srcPath.c_str(), this->Makefile->GetCurrentDirectory())) { cmOStringStream e; @@ -93,10 +93,15 @@ bool cmAddSubDirectoryCommand::InitialPass // Remove the CurrentDirectory from the srcPath and replace it // with the CurrentOutputDirectory. - binPath = srcPath; - cmSystemTools::ReplaceString(binPath, - this->Makefile->GetCurrentDirectory(), - this->Makefile->GetCurrentOutputDirectory()); + const char* src = this->Makefile->GetCurrentDirectory(); + const char* bin = this->Makefile->GetCurrentOutputDirectory(); + size_t srcLen = strlen(src); + size_t binLen = strlen(bin); + if(srcLen > 0 && src[srcLen-1] == '/') + { --srcLen; } + if(binLen > 0 && bin[binLen-1] == '/') + { --binLen; } + binPath = std::string(bin, binLen) + srcPath.substr(srcLen); } else { diff --git a/Source/cmBuildCommand.cxx b/Source/cmBuildCommand.cxx index 3722ab6..91d55a5 100644 --- a/Source/cmBuildCommand.cxx +++ b/Source/cmBuildCommand.cxx @@ -87,6 +87,14 @@ bool cmBuildCommand const char* makeprogram = this->Makefile->GetDefinition("CMAKE_MAKE_PROGRAM"); + if(!makeprogram) + { + this->Makefile->IssueMessage( + cmake::FATAL_ERROR, + "build_command() requires CMAKE_MAKE_PROGRAM to be defined. " + "Call project() or enable_language() first."); + return true; + } // If null/empty CONFIGURATION argument, GenerateBuildCommand uses 'Debug' // in the currently implemented multi-configuration global generators... diff --git a/Source/cmDocumentGeneratorExpressions.h b/Source/cmDocumentGeneratorExpressions.h index 76a60c3..6cc3f25 100644 --- a/Source/cmDocumentGeneratorExpressions.h +++ b/Source/cmDocumentGeneratorExpressions.h @@ -26,6 +26,8 @@ "strings which contain a '>' for example.\n" \ " $<COMMA> = A literal ','. Used to compare " \ "strings which contain a ',' for example.\n" \ + " $<SEMICOLON> = A literal ';'. Used to prevent " \ + "list expansion on an argument with ';'.\n" \ " $<TARGET_NAME:...> = Marks ... as being the name of a " \ "target. This is required if exporting targets to multiple " \ "dependent export sets. The '...' must be a literal name of a " \ diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx index 204bd9a..326a4ce 100644 --- a/Source/cmDocumentVariables.cxx +++ b/Source/cmDocumentVariables.cxx @@ -1551,7 +1551,14 @@ void cmDocumentVariables::DefineVariables(cmake* cm) ("CMAKE_COMPILER_IS_GNU<LANG>", cmProperty::VARIABLE, "True if the compiler is GNU.", "If the selected <LANG> compiler is the GNU " - "compiler then this is TRUE, if not it is FALSE.",false, + "compiler then this is TRUE, if not it is FALSE. " + "Unlike the other per-language variables, this uses the GNU syntax for " + "identifying languages instead of the CMake syntax. Recognized values of " + "the <LANG> suffix are:\n" + " CC = C compiler\n" + " CXX = C++ compiler\n" + " G77 = Fortran compiler", + false, "Variables for Languages"); cm->DefineProperty diff --git a/Source/cmEnableLanguageCommand.h b/Source/cmEnableLanguageCommand.h index e4bb251..ee963f9 100644 --- a/Source/cmEnableLanguageCommand.h +++ b/Source/cmEnableLanguageCommand.h @@ -65,7 +65,12 @@ public: "any of the extra variables that are created by the project command. " "Example languages are CXX, C, Fortran. " "If OPTIONAL is used, use the CMAKE_<languageName>_COMPILER_WORKS " - "variable to check whether the language has been enabled successfully."; + "variable to check whether the language has been enabled successfully." + "\n" + "This command must be called on file scope (not inside a function) and " + "the language enabled can only be used in the calling project or its " + "subdirectories added by add_subdirectory(). Also note that at present, " + "the OPTIONAL argument does not work."; } cmTypeMacro(cmEnableLanguageCommand, cmCommand); diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index b6600f0..8b8b846 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -74,17 +74,35 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) const char* installDest = this->IEGen->GetDestination(); if(!cmSystemTools::FileIsFullPath(installDest)) { - std::string dest = installDest; - os << "# Compute the installation prefix relative to this file.\n" - << "get_filename_component(_IMPORT_PREFIX " - << "\"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n"; - while(!dest.empty()) + std::string installPrefix = + this->IEGen->GetMakefile()->GetSafeDefinition("CMAKE_INSTALL_PREFIX"); + std::string absDest = installPrefix + "/" + installDest + "/"; + if(strncmp(absDest.c_str(), "/lib/", 5) == 0 || + strncmp(absDest.c_str(), "/lib64/", 7) == 0 || + strncmp(absDest.c_str(), "/usr/lib/", 9) == 0 || + strncmp(absDest.c_str(), "/usr/lib64/", 11) == 0) { - os << - "get_filename_component(_IMPORT_PREFIX \"${_IMPORT_PREFIX}\" PATH)\n"; - dest = cmSystemTools::GetFilenamePath(dest); + // Assume this is a build for system package installation rather than a + // relocatable distribution. Use an absolute prefix because some Linux + // distros symlink /lib to /usr/lib which confuses the relative path + // computation below if we generate for /lib under one prefix and but the + // file is loaded from another. + os << "set(_IMPORT_PREFIX \"" << installPrefix << "\")\n"; + } + else + { + std::string dest = installDest; + os << "# Compute the installation prefix relative to this file.\n" + << "get_filename_component(_IMPORT_PREFIX " + << "\"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n"; + while(!dest.empty()) + { + os << + "get_filename_component(_IMPORT_PREFIX \"${_IMPORT_PREFIX}\" PATH)\n"; + dest = cmSystemTools::GetFilenamePath(dest); + } + os << "\n"; } - os << "\n"; // Import location properties may reference this variable. this->ImportPrefix = "${_IMPORT_PREFIX}/"; diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 470ceca..aa3a73d 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -95,7 +95,8 @@ void cmFindPackageCommand::GenerateDocumentation() "Finds and loads settings from an external project. " "<package>_FOUND will be set to indicate whether the package was found. " "When the package is found package-specific information is provided " - "through variables documented by the package itself. " + "through variables and imported targets documented by the package " + "itself. " "The QUIET option disables messages if the package cannot be found. " "The MODULE option disables the second signature documented below. " "The REQUIRED option stops processing with an error message if the " diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index 7ea58fa..3f59129 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -393,7 +393,7 @@ bool cmGeneratorExpression::IsValidTargetName(const std::string &input) cmsys::RegularExpression targetNameValidator; // The ':' is supported to allow use with IMPORTED targets. At least // Qt 4 and 5 IMPORTED targets use ':' as the namespace delimiter. - targetNameValidator.compile("^[A-Za-z0-9_.:-]+$"); + targetNameValidator.compile("^[A-Za-z0-9_.:+-]+$"); return targetNameValidator.find(input.c_str()); } diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index e2d8777..6618e83 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -227,6 +227,22 @@ static const struct CommaNode : public cmGeneratorExpressionNode } commaNode; //---------------------------------------------------------------------------- +static const struct SemicolonNode : public cmGeneratorExpressionNode +{ + SemicolonNode() {} + + virtual int NumExpectedParameters() const { return 0; } + + std::string Evaluate(const std::vector<std::string> &, + cmGeneratorExpressionContext *, + const GeneratorExpressionContent *, + cmGeneratorExpressionDAGChecker *) const + { + return ";"; + } +} semicolonNode; + +//---------------------------------------------------------------------------- static const struct ConfigurationNode : public cmGeneratorExpressionNode { ConfigurationNode() {} @@ -943,6 +959,8 @@ cmGeneratorExpressionNode* GetNode(const std::string &identifier) return &angle_rNode; else if (identifier == "COMMA") return &commaNode; + else if (identifier == "SEMICOLON") + return &semicolonNode; else if (identifier == "TARGET_PROPERTY") return &targetPropertyNode; else if (identifier == "TARGET_NAME") diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index fcd6f71..df14331 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1086,8 +1086,10 @@ void cmGlobalGenerator::CreateAutomocTargets() if(target.GetPropertyAsBool("AUTOMOC") && !target.IsImported()) { cmQtAutomoc automoc; - automoc.InitializeMocSourceFile(&target); - automocs.push_back(std::make_pair(automoc, &target)); + if(automoc.InitializeMocSourceFile(&target)) + { + automocs.push_back(std::make_pair(automoc, &target)); + } } } } diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index b02457d..fa277b1 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -17,6 +17,8 @@ #include "cmGeneratorTarget.h" #include "cmVersion.h" +#include <algorithm> + const char* cmGlobalNinjaGenerator::NINJA_BUILD_FILE = "build.ninja"; const char* cmGlobalNinjaGenerator::NINJA_RULES_FILE = "rules.ninja"; const char* cmGlobalNinjaGenerator::INDENT = " "; @@ -492,16 +494,20 @@ void cmGlobalNinjaGenerator::Generate() // Used in: // Source/cmMakefile.cxx: void cmGlobalNinjaGenerator -::EnableLanguage(std::vector<std::string>const& languages, - cmMakefile *mf, +::EnableLanguage(std::vector<std::string>const& langs, + cmMakefile* makefile, bool optional) { - if(mf->IsOn("CMAKE_COMPILER_IS_MINGW")) + if (makefile->IsOn("CMAKE_COMPILER_IS_MINGW")) { UsingMinGW = true; - this->EnableMinGWLanguage(mf); + this->EnableMinGWLanguage(makefile); + } + if (std::find(langs.begin(), langs.end(), "Fortran") != langs.end()) + { + cmSystemTools::Error("The Ninja generator does not support Fortran yet."); } - this->cmGlobalGenerator::EnableLanguage(languages, mf, optional); + this->cmGlobalGenerator::EnableLanguage(langs, makefile, optional); } bool cmGlobalNinjaGenerator::UsingMinGW = false; diff --git a/Source/cmInstallExportGenerator.h b/Source/cmInstallExportGenerator.h index ee92906..7aff731 100644 --- a/Source/cmInstallExportGenerator.h +++ b/Source/cmInstallExportGenerator.h @@ -36,6 +36,8 @@ public: cmExportSet* GetExportSet() {return this->ExportSet;} + cmMakefile* GetMakefile() const { return this->Makefile; } + const std::string& GetNamespace() const { return this->Namespace; } protected: diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index f07ebef..dfe8280 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1621,17 +1621,30 @@ cmLocalVisualStudio7Generator return dir_max; } -void cmLocalVisualStudio7Generator +bool cmLocalVisualStudio7Generator ::WriteGroup(const cmSourceGroup *sg, cmTarget& target, std::ostream &fout, const char *libName, std::vector<std::string> *configs) { const std::vector<const cmSourceFile *> &sourceFiles = sg->GetSourceFiles(); + std::vector<cmSourceGroup> const& children = sg->GetGroupChildren(); + + // Write the children to temporary output. + bool hasChildrenWithSources = false; + cmOStringStream tmpOut; + for(unsigned int i=0;i<children.size();++i) + { + if(this->WriteGroup(&children[i], target, tmpOut, libName, configs)) + { + hasChildrenWithSources = true; + } + } + // If the group is empty, don't write it at all. - if(sourceFiles.empty() && sg->GetGroupChildren().empty()) + if(sourceFiles.empty() && !hasChildrenWithSources) { - return; + return false; } // If the group has a name, write the header. @@ -1752,11 +1765,10 @@ void cmLocalVisualStudio7Generator } } - std::vector<cmSourceGroup> const& children = sg->GetGroupChildren(); - - for(unsigned int i=0;i<children.size();++i) + // If the group has children with source files, write the children. + if(hasChildrenWithSources) { - this->WriteGroup(&children[i], target, fout, libName, configs); + fout << tmpOut.str(); } // If the group has a name, write the footer. @@ -1764,6 +1776,8 @@ void cmLocalVisualStudio7Generator { this->WriteVCProjEndGroup(fout); } + + return true; } void cmLocalVisualStudio7Generator:: diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index 5a1d208..d9e2ef0 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -109,7 +109,7 @@ private: FCInfo& fcinfo); void WriteTargetVersionAttribute(std::ostream& fout, cmTarget& target); - void WriteGroup(const cmSourceGroup *sg, + bool WriteGroup(const cmSourceGroup *sg, cmTarget& target, std::ostream &fout, const char *libName, std::vector<std::string> *configs); diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index 10ce641..5730c8c 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -119,10 +119,21 @@ cmQtAutomoc::cmQtAutomoc() } } -void cmQtAutomoc::InitializeMocSourceFile(cmTarget* target) +bool cmQtAutomoc::InitializeMocSourceFile(cmTarget* target) { + cmMakefile* makefile = target->GetMakefile(); + // don't do anything if there is no Qt4 or Qt5Core (which contains moc): + std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR"); + if (qtMajorVersion == "") + { + qtMajorVersion = makefile->GetSafeDefinition("Qt5Core_VERSION_MAJOR"); + } + if (qtMajorVersion != "4" && qtMajorVersion != "5") + { + return false; + } + std::string automocTargetName = target->GetName(); - cmMakefile *makefile = target->GetMakefile(); automocTargetName += "_automoc"; std::string mocCppFile = makefile->GetCurrentOutputDirectory(); mocCppFile += "/"; @@ -134,6 +145,7 @@ void cmQtAutomoc::InitializeMocSourceFile(cmTarget* target) mocCppFile.c_str(), false); target->AddSourceFile(mocCppSource); + return true; } void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) @@ -141,16 +153,6 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) cmMakefile* makefile = target->GetMakefile(); cmLocalGenerator* localGen = makefile->GetLocalGenerator(); const char* targetName = target->GetName(); - // don't do anything if there is no Qt4 or Qt5Core (which contains moc): - std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR"); - if (qtMajorVersion == "") - { - qtMajorVersion = makefile->GetSafeDefinition("Qt5Core_VERSION_MAJOR"); - } - if (qtMajorVersion != "4" && qtMajorVersion != "5") - { - return; - } bool relaxedMode = makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE"); diff --git a/Source/cmQtAutomoc.h b/Source/cmQtAutomoc.h index 962e254..01b68fc 100644 --- a/Source/cmQtAutomoc.h +++ b/Source/cmQtAutomoc.h @@ -23,7 +23,7 @@ public: cmQtAutomoc(); bool Run(const char* targetDirectory); - void InitializeMocSourceFile(cmTarget* target); + bool InitializeMocSourceFile(cmTarget* target); void SetupAutomocTarget(cmTarget* target); private: diff --git a/Source/cmStringCommand.h b/Source/cmStringCommand.h index 4423a90..30dbaa5 100644 --- a/Source/cmStringCommand.h +++ b/Source/cmStringCommand.h @@ -136,6 +136,9 @@ public: " [^ ] Matches any character(s) not inside the brackets\n" " - Inside brackets, specifies an inclusive range between\n" " characters on either side e.g. [a-f] is [abcdef]\n" + " To match a literal - using brackets, make it the first\n" + " or the last character e.g. [+*/-] matches basic\n" + " mathematical operators.\n" " * Matches preceding pattern zero or more times\n" " + Matches preceding pattern one or more times\n" " ? Matches preceding pattern zero or once only\n" @@ -144,6 +147,10 @@ public: " in the REGEX REPLACE operation. Additionally it is saved\n" " by all regular expression-related commands, including \n" " e.g. if( MATCHES ), in the variables CMAKE_MATCH_(0..9).\n" + "*, + and ? have higher precedence than concatenation. | has lower " + "precedence than concatenation. This means that the regular expression " + "\"^ab+d$\" matches \"abbd\" but not \"ababd\", and the regular " + "expression \"^(ab|cd)$\" matches \"ab\" but not \"abd\".\n" "TIMESTAMP will write a string representation of " "the current date and/or time to the output variable.\n" "Should the command be unable to obtain a timestamp " diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index f38b16e..e0d7fa4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -1232,7 +1232,9 @@ void cmTarget::DefineProperties(cmake *cm) ("GENERATOR_FILE_NAME", cmProperty::TARGET, "Generator's file for this target.", "An internal property used by some generators to record the name of " - "project or dsp file associated with this target."); + "project or dsp file associated with this target. Note that at configure " + "time, this property is only set for targets created by " + "include_external_msproject()."); cm->DefineProperty ("SOURCES", cmProperty::TARGET, @@ -2898,7 +2900,8 @@ std::vector<std::string> cmTarget::GetIncludeDirectories(const char *config) ge.Parse(it->Value); std::string result = cge->Evaluate(this->Makefile, config, false, this, 0, 0); - if (!this->Makefile->FindTargetToUse(result.c_str())) + if (!cmGeneratorExpression::IsValidTargetName(result.c_str()) + || !this->Makefile->FindTargetToUse(result.c_str())) { continue; } @@ -2975,7 +2978,9 @@ std::string cmTarget::GetCompileDefinitions(const char *config) for (std::vector<std::string>::const_iterator it = libs.begin(); it != libs.end(); ++it) { - if (this->Makefile->FindTargetToUse(it->c_str())) + if ((cmGeneratorExpression::IsValidTargetName(it->c_str()) + || cmGeneratorExpression::Find(it->c_str()) != std::string::npos) + && this->Makefile->FindTargetToUse(it->c_str())) { depString += sep + "$<TARGET_PROPERTY:" + *it + ",INTERFACE_COMPILE_DEFINITIONS>"; @@ -4748,6 +4753,10 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget *tgt, || (!impliedByUse && !explicitlySet)); cmComputeLinkInformation *info = tgt->GetLinkInformation(config); + if(!info) + { + return propContent; + } const cmComputeLinkInformation::ItemVector &deps = info->GetItems(); bool propInitialized = explicitlySet; @@ -4888,6 +4897,10 @@ bool isLinkDependentProperty(cmTarget *tgt, const std::string &p, const char *config) { cmComputeLinkInformation *info = tgt->GetLinkInformation(config); + if(!info) + { + return false; + } const cmComputeLinkInformation::ItemVector &deps = info->GetItems(); diff --git a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt index b13c13d..3881644 100644 --- a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt +++ b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt @@ -102,7 +102,14 @@ target_compile_definitions(depG INTERFACE TEST_DEF ) + add_executable(targetC targetC.cpp) +if(NOT BORLAND AND NOT WATCOM) + # Linking to a target containing a + should be non-fatal, though it does + # not work at all on Borland or watcom + add_library(wrapc++ empty.cpp) + target_link_libraries(targetC wrapc++) +endif() # The TARGET_PROPERTY expression is duplicated below to test that there is no # shortcutting of the evaluation by returning an empty string. set(_exe_test $<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>) diff --git a/Tests/CMakeCommands/target_link_libraries/empty.cpp b/Tests/CMakeCommands/target_link_libraries/empty.cpp new file mode 100644 index 0000000..ab32cf6 --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/empty.cpp @@ -0,0 +1 @@ +// No content diff --git a/Tests/CMakeCommands/target_link_libraries/targetA.cpp b/Tests/CMakeCommands/target_link_libraries/targetA.cpp index 559aef7..d1321a1 100644 --- a/Tests/CMakeCommands/target_link_libraries/targetA.cpp +++ b/Tests/CMakeCommands/target_link_libraries/targetA.cpp @@ -5,7 +5,7 @@ #include "subdirlib.h" -int main(int argc, char **argv) +int main(int, char **) { DepA a; DepB b; diff --git a/Tests/CMakeCommands/target_link_libraries/targetB.cpp b/Tests/CMakeCommands/target_link_libraries/targetB.cpp index 063d63a..0913a57 100644 --- a/Tests/CMakeCommands/target_link_libraries/targetB.cpp +++ b/Tests/CMakeCommands/target_link_libraries/targetB.cpp @@ -1,7 +1,7 @@ #include "depD.h" -int main(int argc, char **argv) +int main(int, char **) { DepD d; DepA a = d.getA(); diff --git a/Tests/CMakeCommands/target_link_libraries/targetC.cpp b/Tests/CMakeCommands/target_link_libraries/targetC.cpp index ff6ba66..a4ef636 100644 --- a/Tests/CMakeCommands/target_link_libraries/targetC.cpp +++ b/Tests/CMakeCommands/target_link_libraries/targetC.cpp @@ -8,7 +8,7 @@ #error Expected TEST_DEF definition #endif -int main(int argc, char **argv) +int main(int, char **) { DepG g; diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 8c7b87c..5982e8b 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -993,6 +993,16 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Environment") + add_test(QtAutomocNoQt ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/QtAutomocNoQt" + "${CMake_BINARY_DIR}/Tests/QtAutomocNoQt" + ${build_generator_args} + --build-project QtAutomocNoQt + --build-options -DCMAKE_BUILD_TYPE=\${CTEST_CONFIGURATION_TYPE} + ) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/QtAutomocNoQt") + if(QT4_WORKS AND QT_QTGUI_FOUND) add_test(QtAutomoc ${CMAKE_CTEST_COMMAND} --build-and-test diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt index fff7c87..0008c16 100644 --- a/Tests/GeneratorExpression/CMakeLists.txt +++ b/Tests/GeneratorExpression/CMakeLists.txt @@ -47,11 +47,13 @@ add_custom_target(check-part1 ALL -Dtest_strequal_no_yes=$<STREQUAL:No,Yes> -Dtest_strequal_angle_r=$<STREQUAL:$<ANGLE-R>,$<ANGLE-R>> -Dtest_strequal_comma=$<STREQUAL:$<COMMA>,$<COMMA>> + -Dtest_strequal_semicolon=$<STREQUAL:$<SEMICOLON>,$<SEMICOLON>> -Dtest_strequal_angle_r_comma=$<STREQUAL:$<ANGLE-R>,$<COMMA>> -Dtest_strequal_both_empty=$<STREQUAL:,> -Dtest_strequal_one_empty=$<STREQUAL:something,> -Dtest_angle_r=$<ANGLE-R> -Dtest_comma=$<COMMA> + -Dtest_semicolon=$<SEMICOLON> -Dtest_colons_1=$<1::> -Dtest_colons_2=$<1:::> -Dtest_colons_3=$<1:Qt5::Core> diff --git a/Tests/GeneratorExpression/check-part1.cmake b/Tests/GeneratorExpression/check-part1.cmake index 7abfa82..9bef159 100644 --- a/Tests/GeneratorExpression/check-part1.cmake +++ b/Tests/GeneratorExpression/check-part1.cmake @@ -44,11 +44,13 @@ check(test_strequal_yes_no "0") check(test_strequal_no_yes "0") check(test_strequal_angle_r "1") check(test_strequal_comma "1") +check(test_strequal_semicolon "1") check(test_strequal_angle_r_comma "0") check(test_strequal_both_empty "1") check(test_strequal_one_empty "0") check(test_angle_r ">") check(test_comma ",") +check(test_semicolon ";") check(test_colons_1 ":") check(test_colons_2 "::") check(test_colons_3 "Qt5::Core") diff --git a/Tests/Module/ExternalData/CMakeLists.txt b/Tests/Module/ExternalData/CMakeLists.txt index a379dca..8312dca 100644 --- a/Tests/Module/ExternalData/CMakeLists.txt +++ b/Tests/Module/ExternalData/CMakeLists.txt @@ -35,6 +35,7 @@ ExternalData_Add_Test(Data1 -D Paired=DATA{PairedA.dat,PairedB.dat} -D Meta=DATA{MetaTop.dat,REGEX:Meta[ABC].dat} -D Directory=DATA{Directory/,A.dat,REGEX:[BC].dat} + -D "Semicolons=DATA{Data.dat}\\;DATA{Data.dat}" -P ${CMAKE_CURRENT_SOURCE_DIR}/Data1Check.cmake ) ExternalData_Add_Target(Data1) diff --git a/Tests/Module/ExternalData/Data1Check.cmake b/Tests/Module/ExternalData/Data1Check.cmake index f40b76c..5770245 100644 --- a/Tests/Module/ExternalData/Data1Check.cmake +++ b/Tests/Module/ExternalData/Data1Check.cmake @@ -56,3 +56,13 @@ foreach(n A B C) message(SEND_ERROR "Input file:\n ${file}\ndoes not exist!") endif() endforeach() +list(LENGTH Semicolons len) +if("${len}" EQUAL 2) + foreach(file ${Semicolons}) + if(NOT EXISTS "${file}") + message(SEND_ERROR "Input file:\n ${file}\ndoes not exist!") + endif() + endforeach() +else() + message(SEND_ERROR "Semicolons value:\n ${Semicolons}\nis not a list of length 2.") +endif() diff --git a/Tests/QtAutomocNoQt/CMakeLists.txt b/Tests/QtAutomocNoQt/CMakeLists.txt new file mode 100644 index 0000000..b26e471 --- /dev/null +++ b/Tests/QtAutomocNoQt/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 2.8) + +project(QtAutomocNoQt) + +set(CMAKE_AUTOMOC ON) + +add_executable(hello main.c) diff --git a/Tests/QtAutomocNoQt/main.c b/Tests/QtAutomocNoQt/main.c new file mode 100644 index 0000000..8488f4e --- /dev/null +++ b/Tests/QtAutomocNoQt/main.c @@ -0,0 +1,4 @@ +int main(void) +{ + return 0; +} diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index dba772d..4b4bd31 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -52,6 +52,7 @@ if(XCODE_VERSION AND "${XCODE_VERSION}" VERSION_LESS 3) endif() add_RunCMake_test(CMP0019) +add_RunCMake_test(CTest) if(UNIX AND "${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles") add_RunCMake_test(CompilerChange) endif() diff --git a/Tests/RunCMake/CTest/BeforeProject-result.txt b/Tests/RunCMake/CTest/BeforeProject-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CTest/BeforeProject-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CTest/BeforeProject-stderr.txt b/Tests/RunCMake/CTest/BeforeProject-stderr.txt new file mode 100644 index 0000000..354896b --- /dev/null +++ b/Tests/RunCMake/CTest/BeforeProject-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at .*/Modules/CTest.cmake:[0-9]+ \(build_command\): + build_command\(\) requires CMAKE_MAKE_PROGRAM to be defined. Call project\(\) + or enable_language\(\) first. +Call Stack \(most recent call first\): + BeforeProject.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/CTest/BeforeProject.cmake b/Tests/RunCMake/CTest/BeforeProject.cmake new file mode 100644 index 0000000..903ca69 --- /dev/null +++ b/Tests/RunCMake/CTest/BeforeProject.cmake @@ -0,0 +1,2 @@ +include(CTest) +project(${RunCMake_TEST} NONE) diff --git a/Tests/RunCMake/CTest/CMakeLists.txt b/Tests/RunCMake/CTest/CMakeLists.txt new file mode 100644 index 0000000..f6e84c0 --- /dev/null +++ b/Tests/RunCMake/CTest/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 2.8) +if(NOT NoProject) + project(${RunCMake_TEST} NONE) +endif() +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CTest/RunCMakeTest.cmake b/Tests/RunCMake/CTest/RunCMakeTest.cmake new file mode 100644 index 0000000..a6f6842 --- /dev/null +++ b/Tests/RunCMake/CTest/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +set(RunCMake_TEST_OPTIONS -DNoProject=1) +run_cmake(BeforeProject) +unset(RunCMake_TEST_OPTIONS) diff --git a/Tests/RunCMake/ExternalData/RunCMakeTest.cmake b/Tests/RunCMake/ExternalData/RunCMakeTest.cmake index 5ee46c9..ceb2ecf 100644 --- a/Tests/RunCMake/ExternalData/RunCMakeTest.cmake +++ b/Tests/RunCMake/ExternalData/RunCMakeTest.cmake @@ -21,4 +21,7 @@ run_cmake(NormalData2) run_cmake(NormalData3) run_cmake(NormalDataSub1) run_cmake(NotUnderRoot) +run_cmake(Semicolon1) +run_cmake(Semicolon2) +run_cmake(Semicolon3) run_cmake(SubDirectory1) diff --git a/Tests/RunCMake/ExternalData/Semicolon1-stdout.txt b/Tests/RunCMake/ExternalData/Semicolon1-stdout.txt new file mode 100644 index 0000000..361baeb --- /dev/null +++ b/Tests/RunCMake/ExternalData/Semicolon1-stdout.txt @@ -0,0 +1 @@ +-- Data arguments correctly transformed! diff --git a/Tests/RunCMake/ExternalData/Semicolon1.cmake b/Tests/RunCMake/ExternalData/Semicolon1.cmake new file mode 100644 index 0000000..c832860 --- /dev/null +++ b/Tests/RunCMake/ExternalData/Semicolon1.cmake @@ -0,0 +1,14 @@ +include(ExternalData) +set(ExternalData_URL_TEMPLATES + "file:///${CMAKE_CURRENT_SOURCE_DIR}/%(algo)/%(hash)" + ) +set(input Data.txt) +set(output ${CMAKE_CURRENT_BINARY_DIR}/Data.txt) +ExternalData_Expand_Arguments(Data args DATA{${input}} "a\\;b" "c;d" DATA{${input}}) +set(expect "${output};a\\;b;c;d;${output}") +if("x${args}" STREQUAL "x${expect}") + message(STATUS "Data arguments correctly transformed!") +else() + message(FATAL_ERROR "Data arguments transformed to:\n ${args}\n" + "but we expected:\n ${expect}") +endif() diff --git a/Tests/RunCMake/ExternalData/Semicolon2-stdout.txt b/Tests/RunCMake/ExternalData/Semicolon2-stdout.txt new file mode 100644 index 0000000..361baeb --- /dev/null +++ b/Tests/RunCMake/ExternalData/Semicolon2-stdout.txt @@ -0,0 +1 @@ +-- Data arguments correctly transformed! diff --git a/Tests/RunCMake/ExternalData/Semicolon2.cmake b/Tests/RunCMake/ExternalData/Semicolon2.cmake new file mode 100644 index 0000000..1a1ae5f --- /dev/null +++ b/Tests/RunCMake/ExternalData/Semicolon2.cmake @@ -0,0 +1,14 @@ +include(ExternalData) +set(ExternalData_URL_TEMPLATES + "file:///${CMAKE_CURRENT_SOURCE_DIR}/%(algo)/%(hash)" + ) +set(input Data.txt) +set(output ${CMAKE_CURRENT_BINARY_DIR}/Data.txt) +ExternalData_Expand_Arguments(Data args "DATA{${input}};a\\;b;c;d;DATA{${input}}") +set(expect "${output};a\\;b;c;d;${output}") +if("x${args}" STREQUAL "x${expect}") + message(STATUS "Data arguments correctly transformed!") +else() + message(FATAL_ERROR "Data arguments transformed to:\n ${args}\n" + "but we expected:\n ${expect}") +endif() diff --git a/Tests/RunCMake/ExternalData/Semicolon3-stdout.txt b/Tests/RunCMake/ExternalData/Semicolon3-stdout.txt new file mode 100644 index 0000000..ca4a360 --- /dev/null +++ b/Tests/RunCMake/ExternalData/Semicolon3-stdout.txt @@ -0,0 +1 @@ +-- Data arguments correctly not transformed! diff --git a/Tests/RunCMake/ExternalData/Semicolon3.cmake b/Tests/RunCMake/ExternalData/Semicolon3.cmake new file mode 100644 index 0000000..2ae99da --- /dev/null +++ b/Tests/RunCMake/ExternalData/Semicolon3.cmake @@ -0,0 +1,12 @@ +include(ExternalData) +set(ExternalData_URL_TEMPLATES + "file:///${CMAKE_CURRENT_SOURCE_DIR}/%(algo)/%(hash)" + ) +set(input "DATA{a;b}") +ExternalData_Expand_Arguments(Data args "${input}") +if("x${args}" STREQUAL "x${input}") + message(STATUS "Data arguments correctly not transformed!") +else() + message(FATAL_ERROR "Data arguments transformed to:\n ${args}\n" + "but we expected:\n ${input}") +endif() diff --git a/Tests/RunCMake/build_command/BeforeProject-result.txt b/Tests/RunCMake/build_command/BeforeProject-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/build_command/BeforeProject-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/build_command/BeforeProject-stderr.txt b/Tests/RunCMake/build_command/BeforeProject-stderr.txt new file mode 100644 index 0000000..d3d7661 --- /dev/null +++ b/Tests/RunCMake/build_command/BeforeProject-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at BeforeProject.cmake:[0-9]+ \(build_command\): + build_command\(\) requires CMAKE_MAKE_PROGRAM to be defined. Call project\(\) + or enable_language\(\) first. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/build_command/BeforeProject.cmake b/Tests/RunCMake/build_command/BeforeProject.cmake new file mode 100644 index 0000000..15788d1 --- /dev/null +++ b/Tests/RunCMake/build_command/BeforeProject.cmake @@ -0,0 +1,2 @@ +build_command(MAKECOMMAND_DEFAULT_VALUE) +project(${RunCMake_TEST} NONE) diff --git a/Tests/RunCMake/build_command/CMakeLists.txt b/Tests/RunCMake/build_command/CMakeLists.txt index 0fbb948..f6e84c0 100644 --- a/Tests/RunCMake/build_command/CMakeLists.txt +++ b/Tests/RunCMake/build_command/CMakeLists.txt @@ -1,59 +1,5 @@ cmake_minimum_required(VERSION 2.8) -project(${RunCMake_TEST} NONE) -include(${RunCMake_TEST}.cmake) - -# This CMakeLists file is *sometimes expected* to result in a configure error. -# -# expect this to succeed: -# ../bin/Release/cmake -G Xcode -# ../../CMake/Tests/CMakeCommands/build_command -# -# expect this to fail: -# ../bin/Release/cmake -DTEST_ERROR_CONDITIONS:BOOL=ON -G Xcode -# ../../CMake/Tests/CMakeCommands/build_command -# -# This project exists merely to test the CMake command 'build_command'... -# ...even purposefully calling it with known-bad argument lists to cover -# error handling code. -# - -set(cmd "initial") - -message("0. begin") - -if(TEST_ERROR_CONDITIONS) - # Test with no arguments (an error): - build_command() - message("1. cmd='${cmd}'") - - # Test with unknown arguments (also an error): - build_command(cmd BOGUS STUFF) - message("2. cmd='${cmd}'") - - build_command(cmd STUFF BOGUS) - message("3. cmd='${cmd}'") -else() - message("(skipping cases 1, 2 and 3 because TEST_ERROR_CONDITIONS is OFF)") +if(NOT NoProject) + project(${RunCMake_TEST} NONE) endif() - -# Test the one arg signature with none of the optional KEYWORD arguments: -build_command(cmd) -message("4. cmd='${cmd}'") - -# Test the two-arg legacy signature: -build_command(legacy_cmd ${CMAKE_BUILD_TOOL}) -message("5. legacy_cmd='${legacy_cmd}'") -message(" CMAKE_BUILD_TOOL='${CMAKE_BUILD_TOOL}'") - -# Test the optional KEYWORDs: -build_command(cmd CONFIGURATION hoohaaConfig) -message("6. cmd='${cmd}'") - -build_command(cmd PROJECT_NAME hoohaaProject) -message("7. cmd='${cmd}'") - -build_command(cmd TARGET hoohaaTarget) -message("8. cmd='${cmd}'") - -set(cmd "final") -message("9. cmd='${cmd}'") +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/build_command/ErrorsCommon.cmake b/Tests/RunCMake/build_command/ErrorsCommon.cmake new file mode 100644 index 0000000..d224539 --- /dev/null +++ b/Tests/RunCMake/build_command/ErrorsCommon.cmake @@ -0,0 +1,55 @@ +# This CMakeLists file is *sometimes expected* to result in a configure error. +# +# expect this to succeed: +# ../bin/Release/cmake -G Xcode +# ../../CMake/Tests/CMakeCommands/build_command +# +# expect this to fail: +# ../bin/Release/cmake -DTEST_ERROR_CONDITIONS:BOOL=ON -G Xcode +# ../../CMake/Tests/CMakeCommands/build_command +# +# This project exists merely to test the CMake command 'build_command'... +# ...even purposefully calling it with known-bad argument lists to cover +# error handling code. +# + +set(cmd "initial") + +message("0. begin") + +if(TEST_ERROR_CONDITIONS) + # Test with no arguments (an error): + build_command() + message("1. cmd='${cmd}'") + + # Test with unknown arguments (also an error): + build_command(cmd BOGUS STUFF) + message("2. cmd='${cmd}'") + + build_command(cmd STUFF BOGUS) + message("3. cmd='${cmd}'") +else() + message("(skipping cases 1, 2 and 3 because TEST_ERROR_CONDITIONS is OFF)") +endif() + +# Test the one arg signature with none of the optional KEYWORD arguments: +build_command(cmd) +message("4. cmd='${cmd}'") + +# Test the two-arg legacy signature: +build_command(legacy_cmd ${CMAKE_BUILD_TOOL}) +message("5. legacy_cmd='${legacy_cmd}'") +message(" CMAKE_BUILD_TOOL='${CMAKE_BUILD_TOOL}'") + +# Test the optional KEYWORDs: +build_command(cmd CONFIGURATION hoohaaConfig) +message("6. cmd='${cmd}'") + +build_command(cmd PROJECT_NAME hoohaaProject) +message("7. cmd='${cmd}'") + +build_command(cmd TARGET hoohaaTarget) +message("8. cmd='${cmd}'") + +set(cmd "final") +message("9. cmd='${cmd}'") diff --git a/Tests/RunCMake/build_command/ErrorsOFF.cmake b/Tests/RunCMake/build_command/ErrorsOFF.cmake index a243fab..7b9cac6 100644 --- a/Tests/RunCMake/build_command/ErrorsOFF.cmake +++ b/Tests/RunCMake/build_command/ErrorsOFF.cmake @@ -1 +1,2 @@ set(TEST_ERROR_CONDITIONS OFF) +include(ErrorsCommon.cmake) diff --git a/Tests/RunCMake/build_command/ErrorsON-stderr.txt b/Tests/RunCMake/build_command/ErrorsON-stderr.txt index 0be7475..47a84d6 100644 --- a/Tests/RunCMake/build_command/ErrorsON-stderr.txt +++ b/Tests/RunCMake/build_command/ErrorsON-stderr.txt @@ -1,12 +1,21 @@ -CMake Error at CMakeLists.txt:[0-9]+ \(build_command\): +CMake Error at ErrorsCommon.cmake:[0-9]+ \(build_command\): build_command requires at least one argument naming a CMake variable +Call Stack \(most recent call first\): + ErrorsON.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(include\) + 1. cmd='initial' -CMake Error at CMakeLists.txt:[0-9]+ \(build_command\): +CMake Error at ErrorsCommon.cmake:[0-9]+ \(build_command\): build_command unknown argument "BOGUS" +Call Stack \(most recent call first\): + ErrorsON.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(include\) + 2. cmd='initial' -CMake Error at CMakeLists.txt:[0-9]+ \(build_command\): +CMake Error at ErrorsCommon.cmake:[0-9]+ \(build_command\): build_command unknown argument "STUFF" +Call Stack \(most recent call first\): + ErrorsON.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/build_command/ErrorsON.cmake b/Tests/RunCMake/build_command/ErrorsON.cmake index 27814bf..d7b709b 100644 --- a/Tests/RunCMake/build_command/ErrorsON.cmake +++ b/Tests/RunCMake/build_command/ErrorsON.cmake @@ -1 +1,2 @@ set(TEST_ERROR_CONDITIONS ON) +include(ErrorsCommon.cmake) diff --git a/Tests/RunCMake/build_command/RunCMakeTest.cmake b/Tests/RunCMake/build_command/RunCMakeTest.cmake index 4525c57..eaa1d77 100644 --- a/Tests/RunCMake/build_command/RunCMakeTest.cmake +++ b/Tests/RunCMake/build_command/RunCMakeTest.cmake @@ -2,3 +2,7 @@ include(RunCMake) run_cmake(ErrorsOFF) run_cmake(ErrorsON) + +set(RunCMake_TEST_OPTIONS -DNoProject=1) +run_cmake(BeforeProject) +unset(RunCMake_TEST_OPTIONS) |