diff --git a/ChangeLog.manual b/ChangeLog.manual index 493686d49..2a44133e0 100644 --- a/ChangeLog.manual +++ b/ChangeLog.manual @@ -1,3 +1,80 @@ +Changes in CMake 2.8.11-rc3 (since 2.8.11-rc2) +---------------------------------------------- +Brad King (1): + get_filename_component: Document path components more clearly (#14091) + +Rolf Eike Beer (1): + try_compile: add missing fclose() to recently added error case + +Stephen Kelly (1): + Fix clearing of the INCLUDE_DIRECTORIES DIRECTORY property. + +Changes in CMake 2.8.11-rc2 (since 2.8.11-rc1) +---------------------------------------------- +Alex Neundorf (6): + Determine C/CXX/Fortran compiler: minor restructuring + Determine C/CXX/Fortran compiler: fix indentation + rename TI_DSP toolchain to TI, since it works also for the ARM compiler + TI compiler: add automatic detection of prefix and suffixes + Modules/readme.txt: switch from "XXX" to "Xxx" + Modules/readme.txt: make lines a bit shorter for easier readability + +Ben Boeckel (1): + Clang: Add -isystem flag support everywhere + +Bill Hoffman (1): + ExternalProject: Retry on a failed git clone + +Brad King (8): + string: Fix regex documentation of '^' and '$' (#14028) + Rename variable for including current directory in interfaces + Replace in CMAKE__COMPILE_OBJECT rule variables + Test evaluation of per-config COMPILE_DEFINITIONS (#14037) + VS: Fix VS 10/11 .sln headers (#14038) + add_dependencies: Distinguish target v. file dependencies in error (#14050) + automoc: Use a pre-build event in VS >= 7 + Handle usr-move without forcing absolute paths (#14041) + +Clinton Stimpson (2): + FindQt4: If Qt5 is in CMAKE_PREFIX_PATH, be sure to find Qt4 includes. + Qt4: Fix typo setting a variable for FindThreads. + +James Bigler (1): + FindCUDA: Use the PRE_LINK mode only for MSVC >= 10 + +Matthew Woehlke (4): + UseJava.cmake: simplify path logic + UseJava.cmake: fix passing jars to add_jar + UseJava.cmake: accept jar targets in add_jar + UseJava.cmake: require explicit request to include jars + +Paul Kunysch (1): + CPack: Avoid "format expects 'unsigned int'" warnings + +Petr Kmoch (1): + cmSystemTools: Generalize TrimWhitespace to all whitespace + +Rex Dieter (1): + FindImageMagick: Search versioned suffixes (#14012) + +Rolf Eike Beer (1): + FindRuby: improve version selection + +Stephen Kelly (13): + FindQt4: Set the Qt4_FOUND variable if Qt4 is found + FindQt4: Set the INTERFACE_QT_MAJOR_VERSION for Qt4::QtCore + Document that CMAKE_AUTOMOC works with Qt 5. + FPHSA: Fix FOUND_VAR check to work with if() auto-dereference + Fix cmGeneratorExpression::Preprocess for interleaved inputs. + cmake-gui: Use the QStandardItemModel workaround until 5.1.0. + Automoc: append implicit includes after user-specified dirs + Fix the evaluation of per-config COMPILE_DEFINITIONS (#14037) + Fix new target commands documentation. + install(EXPORT): Ensure clean INTERFACE_INCLUDE_DIRECTORIES + Report an error on IMPORTED targets with a faulty INTERFACE + Error if linked target has relative paths in INTERFACE_INCLUDE_DIRECTORIES + Fix the Qt 5 version required to run the IncompatibleQt test. + Changes in CMake 2.8.11-rc1 (since 2.8.10.2) ---------------------------------------------- Alan Witkowski (1): diff --git a/Modules/CMakeCCompilerId.c.in b/Modules/CMakeCCompilerId.c.in index 2d76c7a34..c25df0cb5 100644 --- a/Modules/CMakeCCompilerId.c.in +++ b/Modules/CMakeCCompilerId.c.in @@ -109,7 +109,7 @@ # define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR) #elif defined(__TI_COMPILER_VERSION__) -# define COMPILER_ID "TI_DSP" +# define COMPILER_ID "TI" /* __TI_COMPILER_VERSION__ = VVVRRRPPP */ # define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000) # define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000) diff --git a/Modules/CMakeCXXCompilerId.cpp.in b/Modules/CMakeCXXCompilerId.cpp.in index 5e70a4196..e2119c2bf 100644 --- a/Modules/CMakeCXXCompilerId.cpp.in +++ b/Modules/CMakeCXXCompilerId.cpp.in @@ -114,7 +114,7 @@ # define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR) #elif defined(__TI_COMPILER_VERSION__) -# define COMPILER_ID "TI_DSP" +# define COMPILER_ID "TI" /* __TI_COMPILER_VERSION__ = VVVRRRPPP */ # define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000) # define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000) diff --git a/Modules/CMakeDetermineASMCompiler.cmake b/Modules/CMakeDetermineASMCompiler.cmake index 9f0b30ab4..9999f62ab 100644 --- a/Modules/CMakeDetermineASMCompiler.cmake +++ b/Modules/CMakeDetermineASMCompiler.cmake @@ -99,9 +99,9 @@ if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_MSVC "/?") set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_MSVC "Microsoft") - list(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS TI_DSP ) - set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_TI_DSP "-h") - set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_TI_DSP "Texas Instruments") + list(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS TI ) + set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_TI "-h") + set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_TI "Texas Instruments") include(CMakeDetermineCompilerId) CMAKE_DETERMINE_COMPILER_ID_VENDOR(ASM${ASM_DIALECT}) diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index 275fc4758..d2220e09e 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -145,19 +145,27 @@ endif () # NAME_WE cannot be used since then this test will fail for names lile # "arm-unknown-nto-qnx6.3.0-gcc.exe", where BASENAME would be # "arm-unknown-nto-qnx6" instead of the correct "arm-unknown-nto-qnx6.3.0-" -if (CMAKE_CROSSCOMPILING - AND "${CMAKE_C_COMPILER_ID}" MATCHES "GNU" - AND NOT _CMAKE_TOOLCHAIN_PREFIX) - get_filename_component(COMPILER_BASENAME "${CMAKE_C_COMPILER}" NAME) - if (COMPILER_BASENAME MATCHES "^(.+-)g?cc(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$") - set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) - endif () - - # if "llvm-" is part of the prefix, remove it, since llvm doesn't have its own binutils - # but uses the regular ar, objcopy, etc. (instead of llvm-objcopy etc.) - if ("${_CMAKE_TOOLCHAIN_PREFIX}" MATCHES "(.+-)?llvm-$") - set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) - endif () +if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX) + + if("${CMAKE_C_COMPILER_ID}" MATCHES "GNU") + get_filename_component(COMPILER_BASENAME "${CMAKE_C_COMPILER}" NAME) + if (COMPILER_BASENAME MATCHES "^(.+-)g?cc(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$") + set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) + endif () + + # if "llvm-" is part of the prefix, remove it, since llvm doesn't have its own binutils + # but uses the regular ar, objcopy, etc. (instead of llvm-objcopy etc.) + if ("${_CMAKE_TOOLCHAIN_PREFIX}" MATCHES "(.+-)?llvm-$") + set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) + endif () + elseif("${CMAKE_C_COMPILER_ID}" MATCHES "TI") + # TI compilers are named e.g. cl6x, cl470 or armcl.exe + get_filename_component(COMPILER_BASENAME "${CMAKE_C_COMPILER}" NAME) + if (COMPILER_BASENAME MATCHES "^(.+)?cl([^.]+)?(\\.exe)?$") + set(_CMAKE_TOOLCHAIN_PREFIX "${CMAKE_MATCH_1}") + set(_CMAKE_TOOLCHAIN_SUFFIX "${CMAKE_MATCH_2}") + endif () + endif() endif () diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index 59da3e60d..6f7e8f6d4 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -141,19 +141,30 @@ endif () # NAME_WE cannot be used since then this test will fail for names lile # "arm-unknown-nto-qnx6.3.0-gcc.exe", where BASENAME would be # "arm-unknown-nto-qnx6" instead of the correct "arm-unknown-nto-qnx6.3.0-" -if (CMAKE_CROSSCOMPILING - AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" - AND NOT _CMAKE_TOOLCHAIN_PREFIX) - get_filename_component(COMPILER_BASENAME "${CMAKE_CXX_COMPILER}" NAME) - if (COMPILER_BASENAME MATCHES "^(.+-)[gc]\\+\\+(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$") - set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) - endif () - - # if "llvm-" is part of the prefix, remove it, since llvm doesn't have its own binutils - # but uses the regular ar, objcopy, etc. (instead of llvm-objcopy etc.) - if ("${_CMAKE_TOOLCHAIN_PREFIX}" MATCHES "(.+-)?llvm-$") - set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) - endif () + + +if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX) + + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") + get_filename_component(COMPILER_BASENAME "${CMAKE_CXX_COMPILER}" NAME) + if (COMPILER_BASENAME MATCHES "^(.+-)[gc]\\+\\+(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$") + set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) + endif () + + # if "llvm-" is part of the prefix, remove it, since llvm doesn't have its own binutils + # but uses the regular ar, objcopy, etc. (instead of llvm-objcopy etc.) + if ("${_CMAKE_TOOLCHAIN_PREFIX}" MATCHES "(.+-)?llvm-$") + set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) + endif () + elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "TI") + # TI compilers are named e.g. cl6x, cl470 or armcl.exe + get_filename_component(COMPILER_BASENAME "${CMAKE_CXX_COMPILER}" NAME) + if (COMPILER_BASENAME MATCHES "^(.+)?cl([^.]+)?(\\.exe)?$") + set(_CMAKE_TOOLCHAIN_PREFIX "${CMAKE_MATCH_1}") + set(_CMAKE_TOOLCHAIN_SUFFIX "${CMAKE_MATCH_2}") + endif () + + endif() endif () diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake index f861e3954..4d3fb9076 100644 --- a/Modules/CMakeDetermineFortranCompiler.cmake +++ b/Modules/CMakeDetermineFortranCompiler.cmake @@ -200,19 +200,21 @@ endif () # NAME_WE cannot be used since then this test will fail for names lile # "arm-unknown-nto-qnx6.3.0-gcc.exe", where BASENAME would be # "arm-unknown-nto-qnx6" instead of the correct "arm-unknown-nto-qnx6.3.0-" -if (CMAKE_CROSSCOMPILING - AND "${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU" - AND NOT _CMAKE_TOOLCHAIN_PREFIX) - get_filename_component(COMPILER_BASENAME "${CMAKE_Fortran_COMPILER}" NAME) - if (COMPILER_BASENAME MATCHES "^(.+-)g?fortran(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$") - set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) - endif () - - # if "llvm-" is part of the prefix, remove it, since llvm doesn't have its own binutils - # but uses the regular ar, objcopy, etc. (instead of llvm-objcopy etc.) - if ("${_CMAKE_TOOLCHAIN_PREFIX}" MATCHES "(.+-)?llvm-$") - set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) - endif () +if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX) + + if("${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU") + get_filename_component(COMPILER_BASENAME "${CMAKE_Fortran_COMPILER}" NAME) + if (COMPILER_BASENAME MATCHES "^(.+-)g?fortran(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$") + set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) + endif () + + # if "llvm-" is part of the prefix, remove it, since llvm doesn't have its own binutils + # but uses the regular ar, objcopy, etc. (instead of llvm-objcopy etc.) + if ("${_CMAKE_TOOLCHAIN_PREFIX}" MATCHES "(.+-)?llvm-$") + set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) + endif () + endif() + endif () include(CMakeFindBinUtils) diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index e08c1c6a5..e70c013be 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -41,14 +41,14 @@ if("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC" # in all other cases search for ar, ranlib, etc. else() - find_program(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + find_program(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar${_CMAKE_TOOLCHAIN_SUFFIX} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) find_program(CMAKE_RANLIB NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ranlib HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) if(NOT CMAKE_RANLIB) set(CMAKE_RANLIB : CACHE INTERNAL "noop for ranlib") endif() - find_program(CMAKE_STRIP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}strip HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + find_program(CMAKE_STRIP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}strip${_CMAKE_TOOLCHAIN_SUFFIX} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) find_program(CMAKE_LINKER NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ld HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) find_program(CMAKE_NM NAMES ${_CMAKE_TOOLCHAIN_PREFIX}nm HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) find_program(CMAKE_OBJDUMP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objdump HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) diff --git a/Modules/CMakePackageConfigHelpers.cmake b/Modules/CMakePackageConfigHelpers.cmake index 393d05c80..d042d5e0f 100644 --- a/Modules/CMakePackageConfigHelpers.cmake +++ b/Modules/CMakePackageConfigHelpers.cmake @@ -9,8 +9,6 @@ # configure_file() command when creating the Config.cmake or -config.cmake # file for installing a project or library. It helps making the resulting package # relocatable by avoiding hardcoded paths in the installed Config.cmake file. -# Config.cmake files installed under UNIX into /lib(64) or /usr/lib(64) are -# considered system packages and are not relocatable. # # In a FooConfig.cmake file there may be code like this to make the # install destinations know to the using project: @@ -176,32 +174,17 @@ function(CONFIGURE_PACKAGE_CONFIG_FILE _inputFile _outputFile) set(absInstallDir "${CMAKE_INSTALL_PREFIX}/${CCF_INSTALL_DESTINATION}") endif() - # with the /usr-move, /lib(64) is a symlink to /usr/lib on Fedora, ArchLinux, Mageira and others. - # If we are installed to such a location, force using absolute paths. - set(forceAbsolutePaths FALSE) - if("${absInstallDir}" MATCHES "^(/usr)?/lib(64)?/.+") - set(forceAbsolutePaths TRUE) - endif() - file(RELATIVE_PATH PACKAGE_RELATIVE_PATH "${absInstallDir}" "${CMAKE_INSTALL_PREFIX}" ) foreach(var ${CCF_PATH_VARS}) if(NOT DEFINED ${var}) message(FATAL_ERROR "Variable ${var} does not exist") else() - if(forceAbsolutePaths) - if(IS_ABSOLUTE "${${var}}") - set(PACKAGE_${var} "${${var}}") - else() - set(PACKAGE_${var} "${CMAKE_INSTALL_PREFIX}/${${var}}") - endif() + if(IS_ABSOLUTE "${${var}}") + string(REPLACE "${CMAKE_INSTALL_PREFIX}" "\${PACKAGE_PREFIX_DIR}" + PACKAGE_${var} "${${var}}") else() - if(IS_ABSOLUTE "${${var}}") - string(REPLACE "${CMAKE_INSTALL_PREFIX}" "\${PACKAGE_PREFIX_DIR}" - PACKAGE_${var} "${${var}}") - else() - set(PACKAGE_${var} "\${PACKAGE_PREFIX_DIR}/${${var}}") - endif() + set(PACKAGE_${var} "\${PACKAGE_PREFIX_DIR}/${${var}}") endif() endif() endforeach() @@ -216,6 +199,21 @@ function(CONFIGURE_PACKAGE_CONFIG_FILE _inputFile _outputFile) get_filename_component(PACKAGE_PREFIX_DIR \"\${CMAKE_CURRENT_LIST_DIR}/${PACKAGE_RELATIVE_PATH}\" ABSOLUTE) ") + if("${absInstallDir}" MATCHES "^(/usr)?/lib(64)?/.+") + # Handle "/usr move" symlinks created by some Linux distros. + set(PACKAGE_INIT "${PACKAGE_INIT} +# Use original install prefix when loaded through a \"/usr move\" +# cross-prefix symbolic link such as /lib -> /usr/lib. +get_filename_component(_realCurr \"\${CMAKE_CURRENT_LIST_DIR}\" REALPATH) +get_filename_component(_realOrig \"${absInstallDir}\" REALPATH) +if(_realCurr STREQUAL _realOrig) + set(PACKAGE_PREFIX_DIR \"${CMAKE_INSTALL_PREFIX}\") +endif() +unset(_realOrig) +unset(_realCurr) +") + endif() + if(NOT CCF_NO_SET_AND_CHECK_MACRO) set(PACKAGE_INIT "${PACKAGE_INIT} macro(set_and_check _var _file) diff --git a/Modules/Compiler/Clang.cmake b/Modules/Compiler/Clang.cmake index 75a971dd7..c6cd8f8f5 100644 --- a/Modules/Compiler/Clang.cmake +++ b/Modules/Compiler/Clang.cmake @@ -23,4 +23,5 @@ include(Compiler/GNU) macro(__compiler_clang lang) __compiler_gnu(${lang}) set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE") + set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ") endmacro() diff --git a/Modules/Compiler/TI_DSP-ASM.cmake b/Modules/Compiler/TI-ASM.cmake similarity index 100% rename from Modules/Compiler/TI_DSP-ASM.cmake rename to Modules/Compiler/TI-ASM.cmake diff --git a/Modules/Compiler/TI_DSP-C.cmake b/Modules/Compiler/TI-C.cmake similarity index 100% rename from Modules/Compiler/TI_DSP-C.cmake rename to Modules/Compiler/TI-C.cmake diff --git a/Modules/Compiler/TI_DSP-CXX.cmake b/Modules/Compiler/TI-CXX.cmake similarity index 100% rename from Modules/Compiler/TI_DSP-CXX.cmake rename to Modules/Compiler/TI-CXX.cmake diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index bf2892b74..40e14d516 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -287,11 +287,21 @@ if(error_code) message(FATAL_ERROR \"Failed to remove directory: '${source_dir}'\") endif() -execute_process( - COMMAND \"${git_EXECUTABLE}\" clone \"${git_repository}\" \"${src_name}\" - WORKING_DIRECTORY \"${work_dir}\" - RESULT_VARIABLE error_code - ) +# try the clone 3 times incase there is an odd git clone issue +set(error_code 1) +set(number_of_tries 0) +while(error_code AND number_of_tries LESS 3) + execute_process( + COMMAND \"${git_EXECUTABLE}\" clone \"${git_repository}\" \"${src_name}\" + WORKING_DIRECTORY \"${work_dir}\" + RESULT_VARIABLE error_code + ) + math(EXPR number_of_tries \"\${number_of_tries} + 1\") +endwhile() +if(number_of_tries GREATER 1) + message(STATUS \"Had to git clone more than once: + \${number_of_tries} times.\") +endif() if(error_code) message(FATAL_ERROR \"Failed to clone repository: '${git_repository}'\") endif() diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index 61d6ea771..423ad3d13 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -1341,13 +1341,6 @@ endfunction() 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 @@ -1379,12 +1372,34 @@ function(CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS output_file cuda_target options 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}" - ) + + # Some generators don't handle the multiple levels of custom command + # dependencies correctly (obj1 depends on file1, obj2 depends on obj1), so + # we work around that issue by compiling the intermediate link object as a + # pre-link custom command in that situation. + set(do_obj_build_rule TRUE) + if (MSVC_VERSION GREATER 1599) + # VS 2010 and 2012 have this problem. If future versions fix this issue, + # it should still work, it just won't be as nice as the other method. + set(do_obj_build_rule FALSE) + endif() + + if (do_obj_build_rule) + add_custom_command( + OUTPUT ${output_file} + DEPENDS ${object_files} + COMMAND ${CUDA_NVCC_EXECUTABLE} ${nvcc_flags} -dlink ${object_files} -o ${output_file} + ${flags} + COMMENT "Building NVCC intermediate link file ${output_file_relative_path}" + ) + else() + 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() endif() endfunction() diff --git a/Modules/FindImageMagick.cmake b/Modules/FindImageMagick.cmake index 4aaefb75c..cd97b3845 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++-Q16 Magick++-Q8 + Magick++ CORE_RL_Magick++_ Magick++-6.Q16 Magick++-Q16 Magick++-6.Q8 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_ MagickWand-Q16 MagickWand-Q8 + Wand MagickWand CORE_RL_wand_ MagickWand-6.Q16 MagickWand-Q16 MagickWand-6.Q8 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_ MagickCore-Q16 MagickCore-Q8 + Magick MagickCore CORE_RL_magick_ MagickCore-6.Q16 MagickCore-Q16 MagickCore-6.Q8 MagickCore-Q8 ) list(APPEND ImageMagick_REQUIRED_VARS ImageMagick_MagickCore_LIBRARY) else() diff --git a/Modules/FindPackageHandleStandardArgs.cmake b/Modules/FindPackageHandleStandardArgs.cmake index 5f92a8642..70423a7e4 100644 --- a/Modules/FindPackageHandleStandardArgs.cmake +++ b/Modules/FindPackageHandleStandardArgs.cmake @@ -195,7 +195,7 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) string(TOLOWER ${_NAME} _NAME_LOWER) if(FPHSA_FOUND_VAR) - if("${FPHSA_FOUND_VAR}" MATCHES "^${_NAME}_FOUND$" OR "${FPHSA_FOUND_VAR}" MATCHES "^${_NAME_UPPER}_FOUND$") + if(FPHSA_FOUND_VAR MATCHES "^${_NAME}_FOUND$" OR FPHSA_FOUND_VAR MATCHES "^${_NAME_UPPER}_FOUND$") set(_FOUND_VAR ${FPHSA_FOUND_VAR}) else() message(FATAL_ERROR "The argument for FOUND_VAR is \"${FPHSA_FOUND_VAR}\", but only \"${_NAME}_FOUND\" and \"${_NAME_UPPER}_FOUND\" are valid names.") diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index 1dd2782ed..21e8e91fa 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -187,7 +187,8 @@ # # Below is a detailed list of variables that FindQt4.cmake sets. # QT_FOUND If false, don't try to use Qt. -# QT4_FOUND If false, don't try to use Qt 4. +# Qt4_FOUND If false, don't try to use Qt 4. +# QT4_FOUND If false, don't try to use Qt 4. This variable is for compatibility only. # # QT_VERSION_MAJOR The major version of Qt found. # QT_VERSION_MINOR The minor version of Qt found. @@ -685,7 +686,14 @@ if (QT_QMAKE_EXECUTABLE AND QTVERSION) find_path(QT_QTCORE_INCLUDE_DIR QtCore HINTS ${qt_headers} ${QT_LIBRARY_DIR} PATH_SUFFIXES QtCore qt4/QtCore + NO_DEFAULT_PATH ) + if(NOT QT_QTCORE_INCLUDE_DIR) + find_path(QT_QTCORE_INCLUDE_DIR QtCore + HINTS ${qt_headers} ${QT_LIBRARY_DIR} + PATH_SUFFIXES QtCore qt4/QtCore + ) + endif() # Set QT_HEADERS_DIR based on finding QtCore header if(QT_QTCORE_INCLUDE_DIR) @@ -1022,6 +1030,12 @@ if (QT_QMAKE_EXECUTABLE AND QTVERSION) "${QT_MKSPECS_DIR}/default" ${QT_INCLUDE_DIR} ) + set_property(TARGET Qt4::QtCore PROPERTY + INTERFACE_QT_MAJOR_VERSION 4 + ) + set_property(TARGET Qt4::QtCore APPEND PROPERTY + COMPATIBLE_INTERFACE_STRING QT_MAJOR_VERSION + ) foreach(QT_MODULE ${QT_MODULES}) _QT4_ADJUST_LIB_VARS(${QT_MODULE}) @@ -1358,7 +1372,7 @@ if (NOT QT_VERSION_MAJOR EQUAL 4) endif() endif() else() - FIND_PACKAGE_HANDLE_STANDARD_ARGS(Qt4 + FIND_PACKAGE_HANDLE_STANDARD_ARGS(Qt4 FOUND_VAR Qt4_FOUND REQUIRED_VARS ${_QT4_FOUND_REQUIRED_VARS} VERSION_VAR QTVERSION ) @@ -1373,5 +1387,6 @@ endif() set (QT_MOC_EXE ${QT_MOC_EXECUTABLE} ) set (QT_UIC_EXE ${QT_UIC_EXECUTABLE} ) set( QT_QT_LIBRARY "") -set(QT_FOUND ${QT4_FOUND}) +set(QT4_FOUND ${Qt4_FOUND}) +set(QT_FOUND ${Qt4_FOUND}) diff --git a/Modules/FindRuby.cmake b/Modules/FindRuby.cmake index 119cb63dd..c02158f13 100644 --- a/Modules/FindRuby.cmake +++ b/Modules/FindRuby.cmake @@ -46,15 +46,24 @@ set(_RUBY_POSSIBLE_EXECUTABLE_NAMES ruby) # if 1.9 is required, don't look for ruby18 and ruby1.8, default to version 1.8 if(Ruby_FIND_VERSION_MAJOR AND Ruby_FIND_VERSION_MINOR) set(Ruby_FIND_VERSION_SHORT_NODOT "${Ruby_FIND_VERSION_MAJOR}${RUBY_FIND_VERSION_MINOR}") + # we can't construct that if only major version is given + set(_RUBY_POSSIBLE_EXECUTABLE_NAMES + ruby${Ruby_FIND_VERSION_MAJOR}.${Ruby_FIND_VERSION_MINOR} + ruby${Ruby_FIND_VERSION_MAJOR}${Ruby_FIND_VERSION_MINOR} + ${_RUBY_POSSIBLE_EXECUTABLE_NAMES}) else() set(Ruby_FIND_VERSION_SHORT_NODOT "18") endif() -set(_RUBY_POSSIBLE_EXECUTABLE_NAMES ${_RUBY_POSSIBLE_EXECUTABLE_NAMES} ruby1.9 ruby19) +if(NOT Ruby_FIND_VERSION_EXACT) + list(APPEND _RUBY_POSSIBLE_EXECUTABLE_NAMES ruby1.9 ruby19) -# if we want a version below 1.9, also look for ruby 1.8 -if("${Ruby_FIND_VERSION_SHORT_NODOT}" VERSION_LESS "19") - set(_RUBY_POSSIBLE_EXECUTABLE_NAMES ${_RUBY_POSSIBLE_EXECUTABLE_NAMES} ruby1.8 ruby18) + # if we want a version below 1.9, also look for ruby 1.8 + if("${Ruby_FIND_VERSION_SHORT_NODOT}" VERSION_LESS "19") + list(APPEND _RUBY_POSSIBLE_EXECUTABLE_NAMES ruby1.8 ruby18) + endif() + + list(REMOVE_DUPLICATES _RUBY_POSSIBLE_EXECUTABLE_NAMES) endif() find_program(RUBY_EXECUTABLE NAMES ${_RUBY_POSSIBLE_EXECUTABLE_NAMES}) diff --git a/Modules/Qt4ConfigDependentSettings.cmake b/Modules/Qt4ConfigDependentSettings.cmake index 6db5da18a..88dc8ec5d 100644 --- a/Modules/Qt4ConfigDependentSettings.cmake +++ b/Modules/Qt4ConfigDependentSettings.cmake @@ -260,7 +260,7 @@ if(Q_WS_X11) # X11 libraries Qt always depends on set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${X11_Xext_LIB} ${X11_X11_LIB}) - set(CMAKE_THREAD_PREFER_PTHREADS 1) + set(CMAKE_THREAD_PREFER_PTHREAD 1) find_package(Threads) if(CMAKE_USE_PTHREADS_INIT) set(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${CMAKE_THREAD_LIBS_INIT}) diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake index 1b823a8e9..043869519 100644 --- a/Modules/UseJava.cmake +++ b/Modules/UseJava.cmake @@ -3,11 +3,19 @@ # has already been loaded. See FindJava.cmake for information on how to # load Java into your CMake project. # -# add_jar(TARGET_NAME SRC1 SRC2 .. SRCN RCS1 RCS2 .. RCSN) -# -# This command creates a .jar. It compiles the given source -# files (SRC) and adds the given resource files (RCS) to the jar file. -# If only resource files are given then just a jar file is created. +# add_jar(target_name +# [SOURCES] source1 [source2 ...] [resource1 ...] +# [INCLUDE_JARS jar1 [jar2 ...]] +# ) +# +# This command creates a .jar. It compiles the given source files +# (source) and adds the given resource files (resource) to the jar file. If +# only resource files are given then just a jar file is created. The list of +# include jars are added to the classpath when compiling the java sources and +# also to the dependencies of the target. INCLUDE_JARS also accepts other +# target names created by add_jar. For backwards compatibility, jar files +# listed as sources are ignored (as they have been since the first version of +# this module). # # Additional instructions: # To add compile flags to the target you can set these flags with @@ -190,6 +198,8 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) +include(${CMAKE_CURRENT_LIST_DIR}/CMakeParseArguments.cmake) + function (__java_copy_file src dest comment) add_custom_command( OUTPUT ${dest} @@ -205,7 +215,10 @@ set(_JAVA_CLASS_FILELIST_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/UseJavaClassFilelist.c set(_JAVA_SYMLINK_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/UseJavaSymlinks.cmake) function(add_jar _TARGET_NAME) - set(_JAVA_SOURCE_FILES ${ARGN}) + + cmake_parse_arguments(_add_jar "" "" "SOURCES;INCLUDE_JARS" ${ARGN}) + + set(_JAVA_SOURCE_FILES ${_add_jar_SOURCES} ${_add_jar_UNPARSED_ARGUMENTS}) if (NOT DEFINED CMAKE_JAVA_TARGET_OUTPUT_DIR) set(CMAKE_JAVA_TARGET_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}) @@ -257,6 +270,7 @@ function(add_jar _TARGET_NAME) set(_JAVA_CLASS_FILES) set(_JAVA_COMPILE_FILES) set(_JAVA_DEPENDS) + set(_JAVA_COMPILE_DEPENDS) set(_JAVA_RESOURCE_FILES) foreach(_JAVA_SOURCE_FILE ${_JAVA_SOURCE_FILES}) get_filename_component(_JAVA_EXT ${_JAVA_SOURCE_FILE} EXT) @@ -264,18 +278,18 @@ function(add_jar _TARGET_NAME) get_filename_component(_JAVA_PATH ${_JAVA_SOURCE_FILE} PATH) get_filename_component(_JAVA_FULL ${_JAVA_SOURCE_FILE} ABSOLUTE) - file(RELATIVE_PATH _JAVA_REL_BINARY_PATH ${CMAKE_JAVA_TARGET_OUTPUT_DIR} ${_JAVA_FULL}) - file(RELATIVE_PATH _JAVA_REL_SOURCE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${_JAVA_FULL}) - string(LENGTH ${_JAVA_REL_BINARY_PATH} _BIN_LEN) - string(LENGTH ${_JAVA_REL_SOURCE_PATH} _SRC_LEN) - if (${_BIN_LEN} LESS ${_SRC_LEN}) - set(_JAVA_REL_PATH ${_JAVA_REL_BINARY_PATH}) - else () - set(_JAVA_REL_PATH ${_JAVA_REL_SOURCE_PATH}) - endif () - get_filename_component(_JAVA_REL_PATH ${_JAVA_REL_PATH} PATH) - if (_JAVA_EXT MATCHES ".java") + file(RELATIVE_PATH _JAVA_REL_BINARY_PATH ${CMAKE_JAVA_TARGET_OUTPUT_DIR} ${_JAVA_FULL}) + file(RELATIVE_PATH _JAVA_REL_SOURCE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${_JAVA_FULL}) + string(LENGTH ${_JAVA_REL_BINARY_PATH} _BIN_LEN) + string(LENGTH ${_JAVA_REL_SOURCE_PATH} _SRC_LEN) + if (${_BIN_LEN} LESS ${_SRC_LEN}) + set(_JAVA_REL_PATH ${_JAVA_REL_BINARY_PATH}) + else () + set(_JAVA_REL_PATH ${_JAVA_REL_SOURCE_PATH}) + endif () + get_filename_component(_JAVA_REL_PATH ${_JAVA_REL_PATH} PATH) + list(APPEND _JAVA_COMPILE_FILES ${_JAVA_SOURCE_FILE}) set(_JAVA_CLASS_FILE "${CMAKE_JAVA_CLASS_OUTPUT_PATH}/${_JAVA_REL_PATH}/${_JAVA_FILE}.class") set(_JAVA_CLASS_FILES ${_JAVA_CLASS_FILES} ${_JAVA_CLASS_FILE}) @@ -284,7 +298,7 @@ function(add_jar _TARGET_NAME) OR _JAVA_EXT MATCHES ".war" OR _JAVA_EXT MATCHES ".ear" OR _JAVA_EXT MATCHES ".sar") - list(APPEND CMAKE_JAVA_INCLUDE_PATH ${_JAVA_SOURCE_FILE}) + # Ignored for backward compatibility elseif (_JAVA_EXT STREQUAL "") list(APPEND CMAKE_JAVA_INCLUDE_PATH ${JAVA_JAR_TARGET_${_JAVA_SOURCE_FILE}} ${JAVA_JAR_TARGET_${_JAVA_SOURCE_FILE}_CLASSPATH}) @@ -298,6 +312,25 @@ function(add_jar _TARGET_NAME) endif () endforeach() + foreach(_JAVA_INCLUDE_JAR ${_add_jar_INCLUDE_JARS}) + if (TARGET ${_JAVA_INCLUDE_JAR}) + get_target_property(_JAVA_JAR_PATH ${_JAVA_INCLUDE_JAR} JAR_FILE) + if (_JAVA_JAR_PATH) + set(CMAKE_JAVA_INCLUDE_PATH_FINAL "${CMAKE_JAVA_INCLUDE_PATH_FINAL}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${_JAVA_JAR_PATH}") + list(APPEND CMAKE_JAVA_INCLUDE_PATH ${_JAVA_JAR_PATH}) + list(APPEND _JAVA_DEPENDS ${_JAVA_INCLUDE_JAR}) + list(APPEND _JAVA_COMPILE_DEPENDS ${_JAVA_INCLUDE_JAR}) + else () + message(SEND_ERROR "add_jar: INCLUDE_JARS target ${_JAVA_INCLUDE_JAR} is not a jar") + endif () + else () + set(CMAKE_JAVA_INCLUDE_PATH_FINAL "${CMAKE_JAVA_INCLUDE_PATH_FINAL}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${_JAVA_INCLUDE_JAR}") + list(APPEND CMAKE_JAVA_INCLUDE_PATH "${_JAVA_INCLUDE_JAR}") + list(APPEND _JAVA_DEPENDS "${_JAVA_INCLUDE_JAR}") + list(APPEND _JAVA_COMPILE_DEPENDS "${_JAVA_INCLUDE_JAR}") + endif () + endforeach() + # create an empty java_class_filelist if (NOT EXISTS ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist) file(WRITE ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist "") @@ -314,7 +347,7 @@ function(add_jar _TARGET_NAME) -d ${CMAKE_JAVA_CLASS_OUTPUT_PATH} ${_JAVA_COMPILE_FILES} COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME} - DEPENDS ${_JAVA_COMPILE_FILES} + DEPENDS ${_JAVA_COMPILE_FILES} ${_JAVA_COMPILE_DEPENDS} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMENT "Building Java objects for ${_TARGET_NAME}.jar" ) diff --git a/Modules/readme.txt b/Modules/readme.txt index 9dc1c6ab3..2f119947e 100644 --- a/Modules/readme.txt +++ b/Modules/readme.txt @@ -1,50 +1,65 @@ For more information about how to contribute modules to CMake, see this page: http://www.itk.org/Wiki/CMake:Module_Maintainers -Note to authors of FindXXX.cmake files +Note to authors of FindXxx.cmake files -We would like all FindXXX.cmake files to produce consistent variable names. +We would like all FindXxx.cmake files to produce consistent variable names. Please use the following consistent variable names for general use. -XXX_INCLUDE_DIRS The final set of include directories listed in one variable for use by client code. This should not be a cache entry. -XXX_LIBRARIES The libraries to link against to use XXX. These should include full paths. This should not be a cache entry. -XXX_DEFINITIONS Definitions to use when compiling code that uses XXX. This really shouldn't include options such as (-DHAS_JPEG)that a client source-code file uses to decide whether to #include -XXX_EXECUTABLE Where to find the XXX tool. -XXX_YYY_EXECUTABLE Where to find the YYY tool that comes with XXX. -XXX_LIBRARY_DIRS Optionally, the final set of library directories listed in one variable for use by client code. This should not be a cache entry. -XXX_ROOT_DIR Where to find the base directory of XXX. -XXX_VERSION_YY Expect Version YY if true. Make sure at most one of these is ever true. -XXX_WRAP_YY If False, do not try to use the relevent CMake wrapping command. -XXX_YY_FOUND If False, optional YY part of XXX sytem is not available. -XXX_FOUND Set to false, or undefined, if we haven't found, or don't want to use XXX. -XXX_NOT_FOUND_MESSAGE Should be set by config-files in the case that it has set XXX_FOUND to FALSE. +Xxx_INCLUDE_DIRS The final set of include directories listed in one variable for use by client code. + This should not be a cache entry. +Xxx_LIBRARIES The libraries to link against to use Xxx. These should include full paths. + This should not be a cache entry. +Xxx_DEFINITIONS Definitions to use when compiling code that uses Xxx. This really shouldn't include options such + as (-DHAS_JPEG)that a client source-code file uses to decide whether to #include +Xxx_EXECUTABLE Where to find the Xxx tool. +Xxx_Yyy_EXECUTABLE Where to find the Yyy tool that comes with Xxx. +Xxx_LIBRARY_DIRS Optionally, the final set of library directories listed in one variable for use by client code. + This should not be a cache entry. +Xxx_ROOT_DIR Where to find the base directory of Xxx. +Xxx_VERSION_Yy Expect Version Yy if true. Make sure at most one of these is ever true. +Xxx_WRAP_Yy If False, do not try to use the relevant CMake wrapping command. +Xxx_Yy_FOUND If False, optional Yy part of Xxx sytem is not available. +Xxx_FOUND Set to false, or undefined, if we haven't found, or don't want to use Xxx. +Xxx_NOT_FOUND_MESSAGE Should be set by config-files in the case that it has set Xxx_FOUND to FALSE. The contained message will be printed by the find_package() command and by find_package_handle_standard_args() to inform the user about the problem. -XXX_RUNTIME_LIBRARY_DIRS Optionally, the runtime library search path for use when running an executable linked to shared libraries. +Xxx_RUNTIME_LIBRARY_DIRS Optionally, the runtime library search path for use when running an executable linked to + shared libraries. The list should be used by user code to create the PATH on windows or LD_LIBRARY_PATH on unix. This should not be a cache entry. -XXX_VERSION_STRING A human-readable string containing the version of the package found, if any. -XXX_VERSION_MAJOR The major version of the package found, if any. -XXX_VERSION_MINOR The minor version of the package found, if any. -XXX_VERSION_PATCH The patch version of the package found, if any. +Xxx_VERSION_STRING A human-readable string containing the version of the package found, if any. +Xxx_VERSION_MAJOR The major version of the package found, if any. +Xxx_VERSION_MINOR The minor version of the package found, if any. +Xxx_VERSION_PATCH The patch version of the package found, if any. -You do not have to provide all of the above variables. You should provide XXX_FOUND under most circumstances. If XXX is a library, then XXX_LIBRARIES, should also be defined, and XXX_INCLUDE_DIRS should usually be defined (I guess libm.a might be an exception) +You do not have to provide all of the above variables. You should provide Xxx_FOUND under most circumstances. +If Xxx is a library, then Xxx_LIBRARIES, should also be defined, and Xxx_INCLUDE_DIRS should usually be +defined (I guess libm.a might be an exception) -The following names should not usually be used in CMakeLists.txt files, but they may be usefully modified in users' CMake Caches to control stuff. +The following names should not usually be used in CMakeLists.txt files, but they may be usefully modified in +users' CMake Caches to control stuff. -XXX_LIBRARY Name of XXX Library. A User may set this and XXX_INCLUDE_DIR to ignore to force non-use of XXX. -XXX_YY_LIBRARY Name of YY library that is part of the XXX system. It may or may not be required to use XXX. -XXX_INCLUDE_DIR Where to find xxx.h, etc. (XXX_INCLUDE_PATH was considered bad because a path includes an actual filename.) -XXX_YY_INCLUDE_DIR Where to find xxx_yy.h, etc. +Xxx_LIBRARY Name of Xxx Library. A User may set this and Xxx_INCLUDE_DIR to ignore to force non-use of Xxx. +Xxx_Yy_LIBRARY Name of Yy library that is part of the Xxx system. It may or may not be required to use Xxx. +Xxx_INCLUDE_DIR Where to find xxx.h, etc. (Xxx_INCLUDE_PATH was considered bad because a path includes an + actual filename.) +Xxx_Yy_INCLUDE_DIR Where to find xxx_yy.h, etc. -For tidiness's sake, try to keep as many options as possible out of the cache, leaving at least one option which can be used to disable use of the module, or locate a not-found library (e.g. XXX_ROOT_DIR). For the same reason, mark most cache options as advanced. +For tidiness's sake, try to keep as many options as possible out of the cache, leaving at least one option which can be +used to disable use of the module, or locate a not-found library (e.g. Xxx_ROOT_DIR). +For the same reason, mark most cache options as advanced. -If you need other commands to do special things then it should still begin with XXX_. This gives a sort of namespace effect and keeps things tidy for the user. You should put comments describing all the exported settings, plus descriptions of any the users can use to control stuff. +If you need other commands to do special things then it should still begin with Xxx_. This gives a sort of namespace +effect and keeps things tidy for the user. You should put comments describing all the exported settings, plus +descriptions of any the users can use to control stuff. -You really should also provide backwards compatibility any old settings that were actually in use. Make sure you comment them as deprecated, so that no-one starts using them. +You really should also provide backwards compatibility any old settings that were actually in use. +Make sure you comment them as deprecated, so that no-one starts using them. -To correctly document a module, create a comment block at the top with # comments. There are three types of comments that can be in the block: +To correctly document a module, create a comment block at the top with # comments. +There are three types of comments that can be in the block: 1. The brief description of the module, this is done by: # - a small description @@ -67,7 +82,7 @@ For example: # VAR_REALLY_COOL - cool right? # -Test the documentation formatting by running "cmake --help-module FindXXX". +Test the documentation formatting by running "cmake --help-module FindXxx". Edit the comments until the output of this command looks satisfactory. To have a .cmake file in this directory NOT show up in the @@ -93,38 +108,38 @@ copyright and licence notice block like this one: The layout of the notice block is strictly enforced by the ModuleNotices test. Only the year range and name may be changed freely. -A FindXXX.cmake module will typically be loaded by the command +A FindXxx.cmake module will typically be loaded by the command - FIND_PACKAGE(XXX [major[.minor[.patch[.tweak]]]] [EXACT] + FIND_PACKAGE(Xxx [major[.minor[.patch[.tweak]]]] [EXACT] [QUIET] [[REQUIRED|COMPONENTS] [components...]]) If any version numbers are given to the command it will set the following variables before loading the module: - XXX_FIND_VERSION = full requested version string - XXX_FIND_VERSION_MAJOR = major version if requested, else 0 - XXX_FIND_VERSION_MINOR = minor version if requested, else 0 - XXX_FIND_VERSION_PATCH = patch version if requested, else 0 - XXX_FIND_VERSION_TWEAK = tweak version if requested, else 0 - XXX_FIND_VERSION_COUNT = number of version components, 0 to 4 - XXX_FIND_VERSION_EXACT = true if EXACT option was given + Xxx_FIND_VERSION = full requested version string + Xxx_FIND_VERSION_MAJOR = major version if requested, else 0 + Xxx_FIND_VERSION_MINOR = minor version if requested, else 0 + Xxx_FIND_VERSION_PATCH = patch version if requested, else 0 + Xxx_FIND_VERSION_TWEAK = tweak version if requested, else 0 + Xxx_FIND_VERSION_COUNT = number of version components, 0 to 4 + Xxx_FIND_VERSION_EXACT = true if EXACT option was given If the find module supports versioning it should locate a version of the package that is compatible with the version requested. If a compatible version of the package cannot be found the module should not report success. The version of the package found should be stored -in "XXX_VERSION..." version variables documented by the module. +in "Xxx_VERSION..." version variables documented by the module. If the QUIET option is given to the command it will set the variable -XXX_FIND_QUIETLY to true before loading the FindXXX.cmake module. If +Xxx_FIND_QUIETLY to true before loading the FindXxx.cmake module. If this variable is set the module should not complain about not being able to find the package. If the REQUIRED option is given to the command it will set the variable -XXX_FIND_REQUIRED to true before loading the FindXXX.cmake module. If +Xxx_FIND_REQUIRED to true before loading the FindXxx.cmake module. If this variable is set the module should issue a FATAL_ERROR if the package cannot be found. If neither the QUIET nor REQUIRED options are given then the -FindXXX.cmake module should look for the package and complain without +FindXxx.cmake module should look for the package and complain without error if the module is not found. FIND_PACKAGE() will set the variable CMAKE_FIND_PACKAGE_NAME to @@ -133,19 +148,19 @@ contain the actual name of the package. A package can provide sub-components. Those components can be listed after the COMPONENTS (or REQUIRED) or OPTIONAL_COMPONENTS keywords. The set of all listed components will be -specified in a XXX_FIND_COMPONENTS variable. -For each package-specific component, say Yyy, a variable XXX_FIND_REQUIRED_Yyy +specified in a Xxx_FIND_COMPONENTS variable. +For each package-specific component, say Yyy, a variable Xxx_FIND_REQUIRED_Yyy will be set to true if it listed after COMPONENTS and it will be set to false if it was listed after OPTIONAL_COMPONENTS. -Using those variables a FindXXX.cmake module and also a XXXConfig.cmake package +Using those variables a FindXxx.cmake module and also a XxxConfig.cmake package configuration file can determine whether and which components have been requested, and whether they were requested as required or as optional. -For each of the requested components a XXX_Yyy_FOUND variable should be set +For each of the requested components a Xxx_Yyy_FOUND variable should be set accordingly. -The per-package XXX_FOUND variable should be only set to true if all requested +The per-package Xxx_FOUND variable should be only set to true if all requested required components have been found. A missing optional component should not -keep the XXX_FOUND variable from being set to true. -If the package provides XXX_INCLUDE_DIRS and XXX_LIBRARIES variables, the include +keep the Xxx_FOUND variable from being set to true. +If the package provides Xxx_INCLUDE_DIRS and Xxx_LIBRARIES variables, the include dirs and libraries for all components which were requested and which have been found should be added to those two variables. diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index e3335759e..ce99a2c7d 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -3,4 +3,4 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 11) set(CMake_VERSION_TWEAK 0) -set(CMake_VERSION_RC 1) +set(CMake_VERSION_RC 3) diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index f99db5889..4494e8a18 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -771,13 +771,13 @@ static int put_arobj(CF *cfp, struct stat *sb) } if (lname > sizeof(hdr->ar_name) || strchr(name, ' ')) (void)sprintf(ar_hb, HDR1, AR_EFMT1, (int)lname, - (long int)sb->st_mtime, uid, gid, sb->st_mode, - (long long)sb->st_size + lname, ARFMAG); + (long int)sb->st_mtime, (unsigned)uid, (unsigned)gid, + sb->st_mode, (long long)sb->st_size + lname, ARFMAG); else { lname = 0; (void)sprintf(ar_hb, HDR2, name, - (long int)sb->st_mtime, uid, gid, sb->st_mode, - (long long)sb->st_size, ARFMAG); + (long int)sb->st_mtime, (unsigned)uid, (unsigned)gid, + sb->st_mode, (long long)sb->st_size, ARFMAG); } off_t size = sb->st_size; diff --git a/Source/QtDialog/QCMakeCacheView.cxx b/Source/QtDialog/QCMakeCacheView.cxx index 031350ba4..6006758c7 100644 --- a/Source/QtDialog/QCMakeCacheView.cxx +++ b/Source/QtDialog/QCMakeCacheView.cxx @@ -491,7 +491,7 @@ QCMakePropertyList QCMakeCacheModel::properties() const // go to the next in the tree while(!idxs.isEmpty() && ( -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 3) +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) && QT_VERSION < QT_VERSION_CHECK(5, 1, 0) (idxs.last().row()+1) >= rowCount(idxs.last().parent()) || #endif !idxs.last().sibling(idxs.last().row()+1, 0).isValid())) diff --git a/Source/cmAddDependenciesCommand.cxx b/Source/cmAddDependenciesCommand.cxx index a77140d61..04a304e39 100644 --- a/Source/cmAddDependenciesCommand.cxx +++ b/Source/cmAddDependenciesCommand.cxx @@ -35,10 +35,14 @@ bool cmAddDependenciesCommand } else { - std::string error = "Adding dependency to non-existent target: "; - error += target_name; - this->SetError(error.c_str()); - return false; + cmOStringStream e; + e << "Cannot add target-level dependencies to non-existent target \"" + << target_name << "\".\n" + << "The add_dependencies works for top-level logical targets created " + << "by the add_executable, add_library, or add_custom_target commands. " + << "If you want to add file-level dependencies see the DEPENDS option " + << "of the add_custom_target and add_custom_command commands."; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); } return true; diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 387f6ed5b..9f38b2529 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -326,6 +326,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) { this->Makefile->IssueMessage(cmake::FATAL_ERROR, "could not write export file."); + fclose(fout); return -1; } fprintf(fout, diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx index 326a4ce27..50509a0b3 100644 --- a/Source/cmDocumentVariables.cxx +++ b/Source/cmDocumentVariables.cxx @@ -1164,14 +1164,14 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "Variables that Control the Build"); cm->DefineProperty - ("CMAKE_BUILD_INTERFACE_INCLUDES", cmProperty::VARIABLE, + ("CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE", cmProperty::VARIABLE, "Automatically add the current source- and build directories " "to the INTERFACE_INCLUDE_DIRECTORIES.", "If this variable is enabled, CMake automatically adds for each shared " "library target, static library target, module target and executable " "target, ${CMAKE_CURRENT_SOURCE_DIR} and ${CMAKE_CURRENT_BINARY_DIR} to " "the INTERFACE_INCLUDE_DIRECTORIES." - "By default CMAKE_BUILD_INTERFACE_INCLUDES is OFF.", + "By default CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE is OFF.", false, "Variables that Control the Build"); @@ -1499,7 +1499,7 @@ void cmDocumentVariables::DefineVariables(cmake* cm) " PathScale = PathScale (pathscale.com)\n" " SDCC = Small Device C Compiler (sdcc.sourceforge.net)\n" " SunPro = Oracle Solaris Studio (oracle.com)\n" - " TI_DSP = Texas Instruments (ti.com)\n" + " TI = Texas Instruments (ti.com)\n" " TinyCC = Tiny C Compiler (tinycc.org)\n" " Watcom = Open Watcom (openwatcom.org)\n" " XL, VisualAge, zOS = IBM XL (ibm.com)\n" diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 7fd038004..27ec56beb 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -24,6 +24,7 @@ #include "cmComputeLinkInformation.h" #include +#include //---------------------------------------------------------------------------- cmExportFileGenerator::cmExportFileGenerator() @@ -167,6 +168,116 @@ void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName, } } +//---------------------------------------------------------------------------- +static bool isSubDirectory(const char* a, const char* b) +{ + return (cmSystemTools::ComparePath(a, b) || + cmSystemTools::IsSubDirectory(a, b)); +} + +//---------------------------------------------------------------------------- +static bool checkInterfaceDirs(const std::string &prepro, + cmTarget *target) +{ + const char* installDir = + target->GetMakefile()->GetSafeDefinition("CMAKE_INSTALL_PREFIX"); + const char* topSourceDir = target->GetMakefile()->GetHomeDirectory(); + const char* topBinaryDir = target->GetMakefile()->GetHomeOutputDirectory(); + + std::vector parts; + cmGeneratorExpression::Split(prepro, parts); + + const bool inSourceBuild = strcmp(topSourceDir, topBinaryDir) == 0; + + for(std::vector::iterator li = parts.begin(); + li != parts.end(); ++li) + { + if (cmGeneratorExpression::Find(*li) != std::string::npos) + { + continue; + } + if (strncmp(li->c_str(), "${_IMPORT_PREFIX}", 17) == 0) + { + continue; + } + if (!cmSystemTools::FileIsFullPath(li->c_str())) + { + cmOStringStream e; + e << "Target \"" << target->GetName() << "\" " + "INTERFACE_INCLUDE_DIRECTORIES property contains relative path:\n" + " \"" << *li << "\""; + target->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, + e.str().c_str()); + return false; + } + if (isSubDirectory(li->c_str(), installDir)) + { + continue; + } + if (isSubDirectory(li->c_str(), topBinaryDir)) + { + cmOStringStream e; + e << "Target \"" << target->GetName() << "\" " + "INTERFACE_INCLUDE_DIRECTORIES property contains path:\n" + " \"" << *li << "\"\nwhich is prefixed in the build directory."; + target->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, + e.str().c_str()); + return false; + } + if (!inSourceBuild) + { + if (isSubDirectory(li->c_str(), topSourceDir)) + { + cmOStringStream e; + e << "Target \"" << target->GetName() << "\" " + "INTERFACE_INCLUDE_DIRECTORIES property contains path:\n" + " \"" << *li << "\"\nwhich is prefixed in the source directory."; + target->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, + e.str().c_str()); + return false; + } + } + } + return true; +} + +//---------------------------------------------------------------------------- +void cmExportFileGenerator::PopulateIncludeDirectoriesInterface( + cmTarget *target, + cmGeneratorExpression::PreprocessContext preprocessRule, + ImportPropertyMap &properties, + std::vector &missingTargets) +{ + assert(preprocessRule == cmGeneratorExpression::InstallInterface); + + const char *propName = "INTERFACE_INCLUDE_DIRECTORIES"; + const char *input = target->GetProperty(propName); + if (!input) + { + return; + } + if (!*input) + { + // Set to empty + properties[propName] = ""; + return; + } + + std::string prepro = cmGeneratorExpression::Preprocess(input, + preprocessRule); + if (!prepro.empty()) + { + this->ResolveTargetsInGeneratorExpressions(prepro, target, + missingTargets); + + if (!checkInterfaceDirs(prepro, target)) + { + return; + } + properties[propName] = prepro; + } +} + //---------------------------------------------------------------------------- void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName, cmTarget *target, diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 776be614d..9f958a234 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -107,6 +107,11 @@ protected: ImportPropertyMap &properties); void GenerateInterfaceProperties(cmTarget *target, std::ostream& os, const ImportPropertyMap &properties); + void PopulateIncludeDirectoriesInterface( + cmTarget *target, + cmGeneratorExpression::PreprocessContext preprocessRule, + ImportPropertyMap &properties, + std::vector &missingTargets); void SetImportLinkInterface(const char* config, std::string const& suffix, cmGeneratorExpression::PreprocessContext preprocessRule, diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 8b8b8465f..ad12b5a13 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -76,33 +76,36 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) { 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) + std::string absDest = installPrefix + "/" + installDest; + std::string absDestS = absDest + "/"; + os << "# Compute the installation prefix relative to this file.\n" + << "get_filename_component(_IMPORT_PREFIX" + << " \"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n"; + if(strncmp(absDestS.c_str(), "/lib/", 5) == 0 || + strncmp(absDestS.c_str(), "/lib64/", 7) == 0 || + strncmp(absDestS.c_str(), "/usr/lib/", 9) == 0 || + strncmp(absDestS.c_str(), "/usr/lib64/", 11) == 0) { - // 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"; + // Handle "/usr move" symlinks created by some Linux distros. + os << + "# Use original install prefix when loaded through a\n" + "# cross-prefix symbolic link such as /lib -> /usr/lib.\n" + "get_filename_component(_realCurr \"${_IMPORT_PREFIX}\" REALPATH)\n" + "get_filename_component(_realOrig \"" << absDest << "\" REALPATH)\n" + "if(_realCurr STREQUAL _realOrig)\n" + " set(_IMPORT_PREFIX \"" << absDest << "\")\n" + "endif()\n" + "unset(_realOrig)\n" + "unset(_realCurr)\n"; } - else + std::string dest = installDest; + while(!dest.empty()) { - 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 << + "get_filename_component(_IMPORT_PREFIX \"${_IMPORT_PREFIX}\" PATH)\n"; + dest = cmSystemTools::GetFilenamePath(dest); } + os << "\n"; // Import location properties may reference this variable. this->ImportPrefix = "${_IMPORT_PREFIX}/"; @@ -120,8 +123,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) ImportPropertyMap properties; - this->PopulateInterfaceProperty("INTERFACE_INCLUDE_DIRECTORIES", - te, + this->PopulateIncludeDirectoriesInterface(te, cmGeneratorExpression::InstallInterface, properties, missingTargets); this->PopulateInterfaceProperty("INTERFACE_COMPILE_DEFINITIONS", diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 6d5d5b5f6..f6f4ceff3 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -621,7 +621,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, ->GetGeneratorTarget(target); // the compilerdefines for this target - std::string cdefs = target->GetCompileDefinitions(); + std::string cdefs = target->GetCompileDefinitions(buildType); if(!cdefs.empty()) { @@ -640,10 +640,8 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, std::set uniqIncludeDirs; std::vector includes; - const char *config = target->GetMakefile() - ->GetDefinition("CMAKE_BUILD_TYPE"); target->GetMakefile()->GetLocalGenerator()-> - GetIncludeDirectories(includes, gtgt, "C", config); + GetIncludeDirectories(includes, gtgt, "C", buildType); for(std::vector::const_iterator dirIt=includes.begin(); dirIt != includes.end(); ++dirIt) diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 543140164..e4802d59e 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -488,12 +488,11 @@ ComputeDefines(cmSourceFile *source, cmLocalGenerator* lg, cmTarget *target, } // Add preprocessor definitions for this target and configuration. - lg->AppendDefines(defines, target->GetCompileDefinitions()); + lg->AppendDefines(defines, target->GetCompileDefinitions(config)); lg->AppendDefines(defines, source->GetProperty("COMPILE_DEFINITIONS")); { std::string defPropName = "COMPILE_DEFINITIONS_"; defPropName += cmSystemTools::UpperCase(config); - lg->AppendDefines(defines, target->GetCompileDefinitions(config)); lg->AppendDefines(defines, source->GetProperty(defPropName.c_str())); } diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index 3f5912919..ab8bd137e 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -236,9 +236,29 @@ static std::string stripExportInterface(const std::string &input, std::string::size_type pos = 0; std::string::size_type lastPos = pos; - while((pos = input.find("$ FileName\n" - " PATH|ABSOLUTE|NAME|EXT|NAME_WE|REALPATH\n" - " [CACHE])\n" - "Set to be the path (PATH), file name (NAME), file " - "extension (EXT), file name without extension (NAME_WE) of FileName, " - "the full path (ABSOLUTE), or the full path with all symlinks " - "resolved (REALPATH). " - "Note that the path is converted to Unix slashes format and has no " - "trailing slashes. The longest file extension is always considered. " + " get_filename_component( [CACHE])\n" + "Set to a component of , where is one of:\n" + " PATH = Directory without file name\n" + " NAME = File name without directory\n" + " EXT = File name longest extension (.b.c from d/a.b.c)\n" + " NAME_WE = File name without directory or longest extension\n" + " ABSOLUTE = Full path to file\n" + " REALPATH = Full path to existing file with symlinks resolved\n" + "Paths are returned with forward slashes and have no trailing slahes. " + "The longest file extension is always considered. " "If the optional CACHE argument is specified, the result variable is " "added to the cache.\n" " get_filename_component( FileName\n" diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index cac72fc4d..b8c493916 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -102,7 +102,14 @@ void cmGlobalVisualStudio10Generator::AddPlatformDefinitions(cmMakefile* mf) void cmGlobalVisualStudio10Generator::WriteSLNHeader(std::ostream& fout) { fout << "Microsoft Visual Studio Solution File, Format Version 11.00\n"; - fout << "# Visual Studio 2010\n"; + if (this->ExpressEdition) + { + fout << "# Visual C++ Express 2010\n"; + } + else + { + fout << "# Visual Studio 2010\n"; + } } ///! Create a local generator appropriate to this Global Generator diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index b6d7d0452..299aaa8b9 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -81,7 +81,14 @@ cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator( void cmGlobalVisualStudio11Generator::WriteSLNHeader(std::ostream& fout) { fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n"; - fout << "# Visual Studio 11\n"; + if (this->ExpressEdition) + { + fout << "# Visual Studio Express 2012 for Windows Desktop\n"; + } + else + { + fout << "# Visual Studio 2012\n"; + } } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 2222a0e9a..ceac56403 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1709,12 +1709,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->AppendDefines(ppDefs, exportMacro); } cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); - this->AppendDefines(ppDefs, target.GetCompileDefinitions().c_str()); - if(configName) - { - this->AppendDefines(ppDefs, - target.GetCompileDefinitions(configName).c_str()); - } + this->AppendDefines(ppDefs, + target.GetCompileDefinitions(configName).c_str()); buildSettings->AddAttribute ("GCC_PREPROCESSOR_DEFINITIONS", ppDefs.CreateList()); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index dc39fdc8d..ee5b9d812 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1407,20 +1407,22 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector& dirs, return; } - if (stripImplicitInclDirs) - { - // Load implicit include directories for this language. - std::string impDirVar = "CMAKE_"; - impDirVar += lang; - impDirVar += "_IMPLICIT_INCLUDE_DIRECTORIES"; - if(const char* value = this->Makefile->GetDefinition(impDirVar.c_str())) - { - std::vector impDirVec; - cmSystemTools::ExpandListArgument(value, impDirVec); - for(std::vector::const_iterator i = impDirVec.begin(); - i != impDirVec.end(); ++i) + std::vector implicitDirs; + // Load implicit include directories for this language. + std::string impDirVar = "CMAKE_"; + impDirVar += lang; + impDirVar += "_IMPLICIT_INCLUDE_DIRECTORIES"; + if(const char* value = this->Makefile->GetDefinition(impDirVar.c_str())) + { + std::vector impDirVec; + cmSystemTools::ExpandListArgument(value, impDirVec); + for(std::vector::const_iterator i = impDirVec.begin(); + i != impDirVec.end(); ++i) + { + emitted.insert(*i); + if (!stripImplicitInclDirs) { - emitted.insert(*i); + implicitDirs.push_back(*i); } } } @@ -1463,6 +1465,15 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector& dirs, dirs.push_back(*i); } } + + for(std::vector::const_iterator i = implicitDirs.begin(); + i != implicitDirs.end(); ++i) + { + if(std::find(includes.begin(), includes.end(), *i) != includes.end()) + { + dirs.push_back(*i); + } + } } void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index f6ab0d051..0f680f6a1 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1962,7 +1962,6 @@ void cmLocalUnixMakefileGenerator3 // Build a list of preprocessor definitions for the target. std::set defines; - this->AppendDefines(defines, target.GetCompileDefinitions()); this->AppendDefines(defines, target.GetCompileDefinitions( this->ConfigurationName.c_str())); if(!defines.empty()) diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index c35288c52..dc94476c8 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1702,7 +1702,7 @@ void cmLocalVisualStudio6Generator this->AppendDefines( definesSet, - target.GetCompileDefinitions()); + target.GetCompileDefinitions(0)); this->AppendDefines( debugDefinesSet, target.GetCompileDefinitions("DEBUG")); diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index dfe828062..7d0bc67ed 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -745,7 +745,6 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, targetOptions.ParseFinish(); cmGeneratorTarget* gt = this->GlobalGenerator->GetGeneratorTarget(&target); - targetOptions.AddDefines(target.GetCompileDefinitions().c_str()); targetOptions.AddDefines(target.GetCompileDefinitions(configName).c_str()); targetOptions.SetVerboseMakefile( this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 25ccbc739..47a6d2e66 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3458,6 +3458,10 @@ void cmMakefile::SetProperty(const char* prop, const char* value) if (propname == "INCLUDE_DIRECTORIES") { this->IncludeDirectoriesEntries.clear(); + if (!value) + { + return; + } cmListFileBacktrace lfbt; this->GetBacktrace(lfbt); this->IncludeDirectoriesEntries.push_back( diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index d9aa7fed9..4220ae148 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -302,9 +302,6 @@ std::string cmMakefileTargetGenerator::GetDefines(const std::string &l) } // Add preprocessor definitions for this target and configuration. - this->LocalGenerator->AppendDefines - (defines, this->Target->GetCompileDefinitions()); - this->LocalGenerator->AppendDefines (defines, this->Target->GetCompileDefinitions( this->LocalGenerator->ConfigurationName.c_str())); @@ -640,18 +637,25 @@ cmMakefileTargetGenerator (commands, buildEcho.c_str(), cmLocalUnixMakefileGenerator3::EchoBuild); } + std::string targetOutPathReal; std::string targetOutPathPDB; { + std::string targetFullPathReal; std::string targetFullPathPDB; if(this->Target->GetType() == cmTarget::EXECUTABLE || this->Target->GetType() == cmTarget::STATIC_LIBRARY || this->Target->GetType() == cmTarget::SHARED_LIBRARY || this->Target->GetType() == cmTarget::MODULE_LIBRARY) { + targetFullPathReal = + this->Target->GetFullPath(this->ConfigName, false, true); targetFullPathPDB = this->Target->GetPDBDirectory(this->ConfigName); targetFullPathPDB += "/"; targetFullPathPDB += this->Target->GetPDBName(this->ConfigName); } + targetOutPathReal = this->Convert(targetFullPathReal.c_str(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::SHELL); targetOutPathPDB = this->Convert(targetFullPathPDB.c_str(),cmLocalGenerator::NONE, cmLocalGenerator::SHELL); @@ -660,6 +664,7 @@ cmMakefileTargetGenerator vars.RuleLauncher = "RULE_LAUNCH_COMPILE"; vars.CMTarget = this->Target; vars.Language = lang; + vars.Target = targetOutPathReal.c_str(); vars.TargetPDB = targetOutPathPDB.c_str(); vars.Source = sourceFile.c_str(); std::string shellObj = diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 80a1a9b94..3fb823cb0 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -228,16 +228,13 @@ ComputeDefines(cmSourceFile *source, const std::string& language) // Add preprocessor definitions for this target and configuration. this->LocalGenerator->AppendDefines (defines, - this->Target->GetCompileDefinitions()); + this->Target->GetCompileDefinitions(this->GetConfigName())); this->LocalGenerator->AppendDefines (defines, source->GetProperty("COMPILE_DEFINITIONS")); { std::string defPropName = "COMPILE_DEFINITIONS_"; defPropName += cmSystemTools::UpperCase(this->GetConfigName()); - this->LocalGenerator->AppendDefines - (defines, - this->Target->GetCompileDefinitions(this->GetConfigName())); this->LocalGenerator->AppendDefines (defines, source->GetProperty(defPropName.c_str())); diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index 5730c8c9d..a1fa31f2a 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -17,6 +17,10 @@ #include "cmSourceFile.h" #include "cmSystemTools.h" +#if defined(_WIN32) && !defined(__CYGWIN__) +# include "cmLocalVisualStudioGenerator.h" +#endif + #include #include @@ -182,14 +186,44 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) std::string automocComment = "Automoc for target "; automocComment += targetName; - cmTarget* automocTarget = makefile->AddUtilityCommand( - automocTargetName.c_str(), true, - workingDirectory.c_str(), depends, - commandLines, false, automocComment.c_str()); - // inherit FOLDER property from target (#13688) - copyTargetProperty(automocTarget, target, "FOLDER"); - - target->AddUtility(automocTargetName.c_str()); +#if defined(_WIN32) && !defined(__CYGWIN__) + bool usePRE_BUILD = false; + cmGlobalGenerator* gg = localGen->GetGlobalGenerator(); + if(strstr(gg->GetName(), "Visual Studio")) + { + cmLocalVisualStudioGenerator* vslg = + static_cast(localGen); + // Under VS >= 7 use a PRE_BUILD event instead of a separate target to + // reduce the number of targets loaded into the IDE. + // This also works around a VS 11 bug that may skip updating the target: + // https://connect.microsoft.com/VisualStudio/feedback/details/769495 + usePRE_BUILD = vslg->GetVersion() >= cmLocalVisualStudioGenerator::VS7; + } + if(usePRE_BUILD) + { + // Add the pre-build command directly to bypass the OBJECT_LIBRARY + // rejection in cmMakefile::AddCustomCommandToTarget because we know + // PRE_BUILD will work for an OBJECT_LIBRARY in this specific case. + std::vector no_output; + cmCustomCommand cc(makefile, no_output, depends, + commandLines, automocComment.c_str(), + workingDirectory.c_str()); + cc.SetEscapeOldStyle(false); + cc.SetEscapeAllowMakeVars(true); + target->GetPreBuildCommands().push_back(cc); + } + else +#endif + { + cmTarget* automocTarget = makefile->AddUtilityCommand( + automocTargetName.c_str(), true, + workingDirectory.c_str(), depends, + commandLines, false, automocComment.c_str()); + // inherit FOLDER property from target (#13688) + copyTargetProperty(automocTarget, target, "FOLDER"); + + target->AddUtility(automocTargetName.c_str()); + } // configure a file to get all information to automoc at buildtime: std::string _moc_files; @@ -250,7 +284,7 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) std::string _moc_compile_defs; if (tmp) { - _moc_compile_defs = target->GetCompileDefinitions(); + _moc_compile_defs = target->GetCompileDefinitions(0); } tmp = makefile->GetProperty("COMPILE_DEFINITIONS"); if (tmp) diff --git a/Source/cmStringCommand.h b/Source/cmStringCommand.h index 30dbaa5ac..802e0b850 100644 --- a/Source/cmStringCommand.h +++ b/Source/cmStringCommand.h @@ -129,8 +129,8 @@ public: "will search for the position of the last occurrence of the " "specified substring.\n" "The following characters have special meaning in regular expressions:\n" - " ^ Matches at beginning of a line\n" - " $ Matches at end of a line\n" + " ^ Matches at beginning of input\n" + " $ Matches at end of input\n" " . Matches any single character\n" " [ ] Matches any character(s) inside the brackets\n" " [^ ] Matches any character(s) not inside the brackets\n" diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 525efb4a5..67f302391 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -203,13 +203,13 @@ std::string cmSystemTools::EscapeQuotes(const char* str) std::string cmSystemTools::TrimWhitespace(const std::string& s) { std::string::const_iterator start = s.begin(); - while(start != s.end() && *start == ' ') + while(start != s.end() && *start <= ' ') ++start; if (start == s.end()) return ""; std::string::const_iterator stop = s.end()-1; - while(*stop == ' ') + while(*stop <= ' ') --stop; return std::string(start, stop+1); } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e0d7fa425..66c22b16e 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -131,11 +131,13 @@ public: SourceEntriesType SourceEntries; struct IncludeDirectoriesEntry { - IncludeDirectoriesEntry(cmsys::auto_ptr cge) - : ge(cge) + IncludeDirectoriesEntry(cmsys::auto_ptr cge, + const std::string &targetName = std::string()) + : ge(cge), TargetName(targetName) {} const cmsys::auto_ptr ge; std::vector CachedIncludes; + const std::string TargetName; }; std::vector IncludeDirectoriesEntries; std::vector LinkInterfaceIncludeDirectoriesEntries; @@ -193,7 +195,8 @@ void cmTarget::DefineProperties(cmake *cm) "Should the target be processed with automoc (for Qt projects).", "AUTOMOC is a boolean specifying whether CMake will handle " "the Qt moc preprocessor automatically, i.e. without having to use " - "the QT4_WRAP_CPP() macro. Currently Qt4 is supported. " + "the QT4_WRAP_CPP() or QT5_WRAP_CPP() macro. Currently Qt4 and Qt5 are " + "supported. " "When this property is set to TRUE, CMake will scan the source files " "at build time and invoke moc accordingly. " "If an #include statement like #include \"moc_foo.cpp\" is found, " @@ -2744,7 +2747,7 @@ void cmTarget::AppendBuildInterfaceIncludes() } this->BuildInterfaceIncludesAppended = true; - if (this->Makefile->IsOn("CMAKE_BUILD_INTERFACE_INCLUDES")) + if (this->Makefile->IsOn("CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE")) { const char *binDir = this->Makefile->GetStartOutputDirectory(); const char *srcDir = this->Makefile->GetStartDirectory(); @@ -2817,6 +2820,42 @@ static void processIncludeDirectories(cmTarget *tgt, for(std::vector::iterator li = entryIncludes.begin(); li != entryIncludes.end(); ++li) { + cmTarget *dependentTarget = + mf->FindTargetToUse((*it)->TargetName.c_str()); + + const bool fromImported = dependentTarget + && dependentTarget->IsImported(); + + if (fromImported && !cmSystemTools::FileExists(li->c_str())) + { + cmOStringStream e; + e << "Imported target \"" << (*it)->TargetName << "\" includes " + "non-existent path\n \"" << *li << "\"\nin its " + "INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:\n" + "* The path was deleted, renamed, or moved to another " + "location.\n" + "* An install or uninstall procedure did not complete " + "successfully.\n" + "* The installation package was faulty and references files it " + "does not provide.\n"; + tgt->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + return; + } + + if (!cmSystemTools::FileIsFullPath(li->c_str())) + { + if (!(*it)->TargetName.empty()) + { + cmOStringStream e; + e << "Target \"" << (*it)->TargetName << "\" contains relative " + "path in its INTERFACE_INCLUDE_DIRECTORIES:\n" + " \"" << *li << "\" "; + tgt->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, + e.str().c_str()); + return; + } + } + if (testIsOff && !cmSystemTools::IsOff(li->c_str())) { cmSystemTools::ConvertToUnixSlashes(*li); @@ -2912,7 +2951,8 @@ std::vector cmTarget::GetIncludeDirectories(const char *config) it->Value + ",INTERFACE_INCLUDE_DIRECTORIES>"); this->Internal->CachedLinkInterfaceIncludeDirectoriesEntries.push_back( - new cmTargetInternals::IncludeDirectoriesEntry(cge)); + new cmTargetInternals::IncludeDirectoriesEntry(cge, + it->Value)); } } @@ -2941,29 +2981,33 @@ std::vector cmTarget::GetIncludeDirectories(const char *config) //---------------------------------------------------------------------------- std::string cmTarget::GetCompileDefinitions(const char *config) { - std::string defPropName = "COMPILE_DEFINITIONS"; + const char *configProp = 0; if (config) { - defPropName += "_" + cmSystemTools::UpperCase(config); + std::string configPropName; + configPropName = "COMPILE_DEFINITIONS_" + cmSystemTools::UpperCase(config); + configProp = this->GetProperty(configPropName.c_str()); } - const char *prop = this->GetProperty(defPropName.c_str()); + const char *noconfigProp = this->GetProperty("COMPILE_DEFINITIONS"); cmListFileBacktrace lfbt; cmGeneratorExpressionDAGChecker dagChecker(lfbt, this->GetName(), - defPropName, 0, 0); + "COMPILE_DEFINITIONS", 0, 0); - std::string result; - if (prop) + std::string defsString = (noconfigProp ? noconfigProp : ""); + if (configProp && noconfigProp) { - cmGeneratorExpression ge(lfbt); - - result = ge.Parse(prop)->Evaluate(this->Makefile, - config, - false, - this, - &dagChecker); + defsString += ";"; } + defsString += (configProp ? configProp : ""); + + cmGeneratorExpression ge(lfbt); + std::string result = ge.Parse(defsString.c_str())->Evaluate(this->Makefile, + config, + false, + this, + &dagChecker); std::vector libs; this->GetDirectLinkLibraries(config, libs, this); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 0e6dd42da..e25133e58 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -430,7 +430,7 @@ public: If no macro should be defined null is returned. */ const char* GetExportMacro(); - std::string GetCompileDefinitions(const char *config = 0); + std::string GetCompileDefinitions(const char *config); // Compute the set of languages compiled by the target. This is // computed every time it is called because the languages can change diff --git a/Source/cmTargetCompileDefinitionsCommand.h b/Source/cmTargetCompileDefinitionsCommand.h index c93cacb3f..ec9b071db 100644 --- a/Source/cmTargetCompileDefinitionsCommand.h +++ b/Source/cmTargetCompileDefinitionsCommand.h @@ -56,8 +56,7 @@ public: " target_compile_definitions( " " [items1...]\n" " [ [items2...] ...])\n" - "Specify compile definitions or targets to use when compiling a given " - "target. " + "Specify compile definitions to use when compiling a given target. " "The named must have been created by a command such as " "add_executable or add_library and must not be an IMPORTED target. " "The INTERFACE, PUBLIC and PRIVATE keywords are required to specify " @@ -65,8 +64,7 @@ public: "populate the COMPILE_DEFINITIONS property of . PUBLIC and " "INTERFACE items will populate the INTERFACE_COMPILE_DEFINITIONS " "property of . " - "The non-scope arguments specify compile definitions or targets to use " - "INTERFACE_COMPILE_DEFINITIONS from. " + "The following arguments specify compile definitions. " "Repeated calls for the same append items in the order called." "\n" "Arguments to target_compile_definitions may use \"generator " diff --git a/Source/cmTargetIncludeDirectoriesCommand.h b/Source/cmTargetIncludeDirectoriesCommand.h index 2bc7bef05..e4bc9cf67 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.h +++ b/Source/cmTargetIncludeDirectoriesCommand.h @@ -68,9 +68,8 @@ public: "populate the INCLUDE_DIRECTORIES property of . PUBLIC and " "INTERFACE items will populate the INTERFACE_INCLUDE_DIRECTORIES " "property of . " - "The non-scope arguments specify either include directories or targets " - "to use INTERFACE_INCLUDE_DIRECTORIES from. Any specified include " - "directories must be absolute paths, not relative paths. " + "The following arguments specify include directories. Specified " + "include directories may be absolute paths or relative paths. " "Repeated calls for the same append items in the order called." "\n" "Arguments to target_include_directories may use \"generator " diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index f4984c7ed..1cb9f2370 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1220,8 +1220,6 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( clOptions.AddFlag("PrecompiledHeader", "NotUsing"); clOptions.Parse(flags.c_str()); clOptions.Parse(defineFlags.c_str()); - clOptions.AddDefines( - this->Target->GetCompileDefinitions().c_str()); clOptions.AddDefines(this->Target->GetCompileDefinitions( configName.c_str()).c_str()); clOptions.SetVerboseMakefile( diff --git a/Source/kwsys/ProcessUNIX.c b/Source/kwsys/ProcessUNIX.c index fc9e8bf67..b9af2f1f5 100644 --- a/Source/kwsys/ProcessUNIX.c +++ b/Source/kwsys/ProcessUNIX.c @@ -47,6 +47,12 @@ do. */ +#if defined(__CYGWIN__) +/* Increase the file descriptor limit for select() before including + related system headers. (Default: 64) */ +# define FD_SETSIZE 16384 +#endif + #include /* ptrdiff_t */ #include /* snprintf */ #include /* malloc, free */ diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx index f057e0fcb..9e2a93d7c 100644 --- a/Source/kwsys/SystemInformation.cxx +++ b/Source/kwsys/SystemInformation.cxx @@ -130,7 +130,7 @@ typedef int siginfo_t; # define KWSYS_SYSTEMINFORMATION_IMPLEMENT_FQDN # endif # endif -# if defined(__GNUG__) +# if defined(__GNUC__) # include # if !(defined(__LSB_VERSION__) && __LSB_VERSION__ < 41) # define KWSYS_SYSTEMINFORMATION_HAVE_BACKTRACE diff --git a/Tests/CMakeCommands/target_link_libraries/subdir/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/subdir/CMakeLists.txt index 61a1a5988..9d7fa6cb8 100644 --- a/Tests/CMakeCommands/target_link_libraries/subdir/CMakeLists.txt +++ b/Tests/CMakeCommands/target_link_libraries/subdir/CMakeLists.txt @@ -1,5 +1,5 @@ -set(CMAKE_BUILD_INTERFACE_INCLUDES ON) +set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON) add_library(subdirlib SHARED subdirlib.cpp) generate_export_header(subdirlib) diff --git a/Tests/CompileDefinitions/CMakeLists.txt b/Tests/CompileDefinitions/CMakeLists.txt index e7d91bf94..d3e9a3eae 100644 --- a/Tests/CompileDefinitions/CMakeLists.txt +++ b/Tests/CompileDefinitions/CMakeLists.txt @@ -7,10 +7,19 @@ if ("${CMAKE_GENERATOR}" STREQUAL "Visual Studio 6") add_definitions(-DNO_SPACES_IN_DEFINE_VALUES) endif() +# Use compile flags to tell executables which config is built +# without depending on the compile definitions functionality. +foreach(c DEBUG RELEASE RELWITHDEBINFO MINSIZEREL) + set(CMAKE_C_FLAGS_${c} "${CMAKE_C_FLAGS_${c}} -DTEST_CONFIG_${c}") + set(CMAKE_CXX_FLAGS_${c} "${CMAKE_CXX_FLAGS_${c}} -DTEST_CONFIG_${c}") +endforeach() + +set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS + "BUILD_CONFIG_NAME=\"$\"" + ) + add_subdirectory(add_definitions_command) add_subdirectory(target_prop) add_subdirectory(add_definitions_command_with_target_prop) -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/dummyexecutable.cpp" "int main(int, char **) { return 0; }\n") - -add_executable(CompileDefinitions "${CMAKE_CURRENT_BINARY_DIR}/dummyexecutable.cpp") +add_executable(CompileDefinitions runtest.c) diff --git a/Tests/CompileDefinitions/add_definitions_command/CMakeLists.txt b/Tests/CompileDefinitions/add_definitions_command/CMakeLists.txt index a6372af74..d3886a104 100644 --- a/Tests/CompileDefinitions/add_definitions_command/CMakeLists.txt +++ b/Tests/CompileDefinitions/add_definitions_command/CMakeLists.txt @@ -3,5 +3,6 @@ project(add_definitions_command) add_definitions(-DCMAKE_IS_FUN -DCMAKE_IS=Fun -DCMAKE_IS_="Fun" -DCMAKE_IS_REALLY="Very Fun") add_definitions(-DCMAKE_IS_="Fun" -DCMAKE_IS_REALLY="Very Fun" -DCMAKE_IS_FUN -DCMAKE_IS=Fun) +add_definitions(-DBUILD_IS_DEBUG=$ -DBUILD_IS_NOT_DEBUG=$>) add_executable(add_definitions_command_executable ../compiletest.cpp) diff --git a/Tests/CompileDefinitions/add_definitions_command_with_target_prop/CMakeLists.txt b/Tests/CompileDefinitions/add_definitions_command_with_target_prop/CMakeLists.txt index e415390c0..5587f7f99 100644 --- a/Tests/CompileDefinitions/add_definitions_command_with_target_prop/CMakeLists.txt +++ b/Tests/CompileDefinitions/add_definitions_command_with_target_prop/CMakeLists.txt @@ -12,3 +12,6 @@ set_property(TARGET add_definitions_command_with_target_prop_executable APPEND P add_definitions(-DCMAKE_IS_FUN) set_property(TARGET add_definitions_command_with_target_prop_executable APPEND PROPERTY COMPILE_DEFINITIONS CMAKE_IS=Fun CMAKE_IS_="Fun") + +add_definitions(-DBUILD_IS_DEBUG=$) +set_property(TARGET add_definitions_command_with_target_prop_executable APPEND PROPERTY COMPILE_DEFINITIONS BUILD_IS_NOT_DEBUG=$>) diff --git a/Tests/CompileDefinitions/compiletest.cpp b/Tests/CompileDefinitions/compiletest.cpp index f18e59e67..14b8eab4a 100644 --- a/Tests/CompileDefinitions/compiletest.cpp +++ b/Tests/CompileDefinitions/compiletest.cpp @@ -45,6 +45,30 @@ enum { // TEST_GENERATOR_EXPRESSIONS #endif +#ifndef BUILD_IS_DEBUG +# error "BUILD_IS_DEBUG not defined!" +#endif +#ifndef BUILD_IS_NOT_DEBUG +# error "BUILD_IS_NOT_DEBUG not defined!" +#endif + +// Check per-config definitions. +#ifdef TEST_CONFIG_DEBUG +# if !BUILD_IS_DEBUG +# error "BUILD_IS_DEBUG false with TEST_CONFIG_DEBUG!" +# endif +# if BUILD_IS_NOT_DEBUG +# error "BUILD_IS_NOT_DEBUG true with TEST_CONFIG_DEBUG!" +# endif +#else +# if BUILD_IS_DEBUG +# error "BUILD_IS_DEBUG true without TEST_CONFIG_DEBUG!" +# endif +# if !BUILD_IS_NOT_DEBUG +# error "BUILD_IS_NOT_DEBUG false without TEST_CONFIG_DEBUG!" +# endif +#endif + int main(int argc, char **argv) { return 0; diff --git a/Tests/CompileDefinitions/runtest.c b/Tests/CompileDefinitions/runtest.c new file mode 100644 index 000000000..02d2cadb0 --- /dev/null +++ b/Tests/CompileDefinitions/runtest.c @@ -0,0 +1,47 @@ +#include +#include +#include + +#ifndef BUILD_CONFIG_NAME +# error "BUILD_CONFIG_NAME not defined!" +#endif + +int main() +{ + char build_config_name[] = BUILD_CONFIG_NAME; + char* c; + for(c = build_config_name; *c; ++c) + { + *c = (char)tolower((int)*c); + } + fprintf(stderr, "build_config_name=\"%s\"\n", build_config_name); +#ifdef TEST_CONFIG_DEBUG + if(strcmp(build_config_name, "debug") != 0) + { + fprintf(stderr, "build_config_name is not \"debug\"\n"); + return 1; + } +#endif +#ifdef TEST_CONFIG_RELEASE + if(strcmp(build_config_name, "release") != 0) + { + fprintf(stderr, "build_config_name is not \"release\"\n"); + return 1; + } +#endif +#ifdef TEST_CONFIG_MINSIZEREL + if(strcmp(build_config_name, "minsizerel") != 0) + { + fprintf(stderr, "build_config_name is not \"minsizerel\"\n"); + return 1; + } +#endif +#ifdef TEST_CONFIG_RELWITHDEBINFO + if(strcmp(build_config_name, "relwithdebinfo") != 0) + { + fprintf(stderr, "build_config_name is not \"relwithdebinfo\"\n"); + return 1; + } +#endif + return 0; +} diff --git a/Tests/CompileDefinitions/target_prop/CMakeLists.txt b/Tests/CompileDefinitions/target_prop/CMakeLists.txt index abdf257ec..1ef2d6d6e 100644 --- a/Tests/CompileDefinitions/target_prop/CMakeLists.txt +++ b/Tests/CompileDefinitions/target_prop/CMakeLists.txt @@ -14,3 +14,8 @@ set_property(TARGET target_prop_executable APPEND PROPERTY COMPILE_DEFINITIONS "$<0:GE_NOT_DEFINED>" "$<1:ARGUMENT;LIST>" ) + +set_property(TARGET target_prop_executable APPEND PROPERTY COMPILE_DEFINITIONS + BUILD_IS_DEBUG=$ + BUILD_IS_NOT_DEBUG=$> + ) diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index c00ef82bb..be48483da 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -148,6 +148,10 @@ set_property(TARGET testLibRequired APPEND PROPERTY $> $> $> + # The BUILD_INTERFACE entry from above is duplicated below. This is to test that + # the INSTALL_INTERFACE entry bound by a BUILD_INTERFACE entry on either side is + # preprocessed correctly on install(EXPORT). + $> # Test that the below is non-fatal $<$:$> ) @@ -170,9 +174,14 @@ set_property(TARGET testSharedLibRequired set_property(TARGET testSharedLibRequired APPEND PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}" ) +install(FILES + "${CMAKE_CURRENT_SOURCE_DIR}/testSharedLibRequired.h" + "${CMAKE_CURRENT_BINARY_DIR}/testsharedlibrequired_export.h" + DESTINATION include/testSharedLibRequired +) set_property(TARGET testSharedLibRequired APPEND PROPERTY - INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}" - "${CMAKE_CURRENT_SOURCE_DIR}" + INTERFACE_INCLUDE_DIRECTORIES "$/include/testSharedLibRequired>" + "$" ) set_property(TARGET testSharedLibRequired APPEND PROPERTY @@ -201,6 +210,15 @@ set_property(TARGET testSharedLibDepends APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES $ ) +install(FILES + "${CMAKE_CURRENT_SOURCE_DIR}/testSharedLibDepends.h" + "${CMAKE_CURRENT_BINARY_DIR}/testsharedlibdepends_export.h" + DESTINATION include/testSharedLibDepends +) +set_property(TARGET testSharedLibDepends APPEND PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "$/include/testSharedLibDepends>" + "$" +) set_property(TARGET testSharedLibDepends APPEND PROPERTY LINK_INTERFACE_LIBRARIES $<$,EXECUTABLE>:$> @@ -287,7 +305,7 @@ if(WIN32) install(TARGETS testLib5 RUNTIME DESTINATION bin) endif() -add_subdirectory(sublib) # For CMAKE_BUILD_INTERFACE_INCLUDES test. +add_subdirectory(sublib) # For CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE test. # Export from build tree. export(TARGETS testExe1 testLib1 testLib2 testLib3 diff --git a/Tests/ExportImport/Export/sublib/CMakeLists.txt b/Tests/ExportImport/Export/sublib/CMakeLists.txt index 2d11040a9..a5c6413c1 100644 --- a/Tests/ExportImport/Export/sublib/CMakeLists.txt +++ b/Tests/ExportImport/Export/sublib/CMakeLists.txt @@ -1,5 +1,5 @@ -set(CMAKE_BUILD_INTERFACE_INCLUDES ON) +set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON) set(CMAKE_INCLUDE_CURRENT_DIR ON) add_library(subdirlib SHARED subdir.cpp) diff --git a/Tests/IncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/CMakeLists.txt index 60f5e5e6f..8a60f17d8 100644 --- a/Tests/IncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/CMakeLists.txt @@ -47,3 +47,14 @@ else() endif() add_subdirectory(TargetIncludeDirectories) + +set_property(DIRECTORY PROPERTY INCLUDE_DIRECTORIES "${CMAKE_BINARY_DIR}") +get_property(propContent DIRECTORY PROPERTY INCLUDE_DIRECTORIES) +if (NOT propContent STREQUAL "${CMAKE_BINARY_DIR}") + message(SEND_ERROR "Setting DIRECTORY property failed.") +endif() +set_property(DIRECTORY PROPERTY INCLUDE_DIRECTORIES) +get_property(propContentAfter DIRECTORY PROPERTY INCLUDE_DIRECTORIES) +if (NOT propContentAfter STREQUAL "") + message(SEND_ERROR "Clearing DIRECTORY property failed.") +endif() diff --git a/Tests/QtAutomoc/Adir/CMakeLists.txt b/Tests/QtAutomoc/Adir/CMakeLists.txt index abd328e76..171222319 100644 --- a/Tests/QtAutomoc/Adir/CMakeLists.txt +++ b/Tests/QtAutomoc/Adir/CMakeLists.txt @@ -1,7 +1,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) -set(CMAKE_BUILD_INTERFACE_INCLUDES ON) +set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON) add_library(libA SHARED libA.cpp) target_link_libraries(libA LINK_PUBLIC Qt4::QtCore) diff --git a/Tests/QtAutomoc/Bdir/CMakeLists.txt b/Tests/QtAutomoc/Bdir/CMakeLists.txt index 549710571..d9d4aa7fa 100644 --- a/Tests/QtAutomoc/Bdir/CMakeLists.txt +++ b/Tests/QtAutomoc/Bdir/CMakeLists.txt @@ -1,7 +1,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) -set(CMAKE_BUILD_INTERFACE_INCLUDES ON) +set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON) add_library(libB SHARED libB.cpp) generate_export_header(libB) diff --git a/Tests/QtAutomoc/CMakeLists.txt b/Tests/QtAutomoc/CMakeLists.txt index ebfbb0363..fd624c803 100644 --- a/Tests/QtAutomoc/CMakeLists.txt +++ b/Tests/QtAutomoc/CMakeLists.txt @@ -25,7 +25,7 @@ set_target_properties(foo codeeditorLib privateSlot PROPERTIES AUTOMOC TRUE) include(GenerateExportHeader) # The order is relevant here. B depends on A, and B headers depend on A -# headers both subdirectories use CMAKE_BUILD_INTERFACE_INCLUDES and we +# headers both subdirectories use CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE and we # test that CMAKE_AUTOMOC successfully reads the include directories # for the build interface from those targets. There has previously been # a bug where caching of the include directories happened before diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 4b4bd31bc..402c8a980 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -68,6 +68,7 @@ if(NOT WIN32) endif() add_RunCMake_test(CompatibleInterface) +add_RunCMake_test(add_dependencies) add_RunCMake_test(build_command) add_RunCMake_test(find_package) add_RunCMake_test(include) @@ -75,6 +76,12 @@ add_RunCMake_test(include_directories) add_RunCMake_test(list) add_RunCMake_test(CMP0004) +find_package(Qt4 QUIET) +find_package(Qt5Core QUIET) +if (QT4_FOUND AND Qt5Core_FOUND AND NOT Qt5Core_VERSION VERSION_LESS 5.1.0) + add_RunCMake_test(IncompatibleQt) +endif() + if("${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio [^6]") add_RunCMake_test(include_external_msproject) add_RunCMake_test(SolutionGlobalSections) diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceString-builtin-prop.cmake b/Tests/RunCMake/CompatibleInterface/InterfaceString-builtin-prop.cmake index 5221a129c..5772856cc 100644 --- a/Tests/RunCMake/CompatibleInterface/InterfaceString-builtin-prop.cmake +++ b/Tests/RunCMake/CompatibleInterface/InterfaceString-builtin-prop.cmake @@ -3,8 +3,6 @@ add_library(foo UNKNOWN IMPORTED) add_library(bar UNKNOWN IMPORTED) set_property(TARGET foo APPEND PROPERTY COMPATIBLE_INTERFACE_STRING INCLUDE_DIRECTORIES) -set_property(TARGET foo PROPERTY INTERFACE_INCLUDE_DIRECTORIES foo_inc) -set_property(TARGET bar PROPERTY INTERFACE_INCLUDE_DIRECTORIES bar_inc) add_executable(user main.cpp) set_property(TARGET user PROPERTY INCLUDE_DIRECTORIES bar_inc) diff --git a/Tests/RunCMake/IncompatibleQt/CMakeLists.txt b/Tests/RunCMake/IncompatibleQt/CMakeLists.txt new file mode 100644 index 000000000..68dd8d6a1 --- /dev/null +++ b/Tests/RunCMake/IncompatibleQt/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8) +project(${RunCMake_TEST} CXX) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/IncompatibleQt/IncompatibleQt-result.txt b/Tests/RunCMake/IncompatibleQt/IncompatibleQt-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/IncompatibleQt/IncompatibleQt-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/IncompatibleQt/IncompatibleQt-stderr.txt b/Tests/RunCMake/IncompatibleQt/IncompatibleQt-stderr.txt new file mode 100644 index 000000000..4eaaa95f1 --- /dev/null +++ b/Tests/RunCMake/IncompatibleQt/IncompatibleQt-stderr.txt @@ -0,0 +1,3 @@ +CMake Error: The INTERFACE_QT_MAJOR_VERSION property of "Qt5::Core" does +not agree with the value of QT_MAJOR_VERSION already determined +for "mainexe". diff --git a/Tests/RunCMake/IncompatibleQt/IncompatibleQt.cmake b/Tests/RunCMake/IncompatibleQt/IncompatibleQt.cmake new file mode 100644 index 000000000..4fccdc418 --- /dev/null +++ b/Tests/RunCMake/IncompatibleQt/IncompatibleQt.cmake @@ -0,0 +1,6 @@ + +find_package(Qt4 REQUIRED) +find_package(Qt5Core REQUIRED) + +add_executable(mainexe main.cpp) +target_link_libraries(mainexe Qt4::QtCore Qt5::Core) diff --git a/Tests/RunCMake/IncompatibleQt/RunCMakeTest.cmake b/Tests/RunCMake/IncompatibleQt/RunCMakeTest.cmake new file mode 100644 index 000000000..322c291b7 --- /dev/null +++ b/Tests/RunCMake/IncompatibleQt/RunCMakeTest.cmake @@ -0,0 +1,3 @@ +include(RunCMake) + +run_cmake(IncompatibleQt) diff --git a/Tests/RunCMake/IncompatibleQt/main.cpp b/Tests/RunCMake/IncompatibleQt/main.cpp new file mode 100644 index 000000000..140a7c1a6 --- /dev/null +++ b/Tests/RunCMake/IncompatibleQt/main.cpp @@ -0,0 +1,8 @@ + +#include + +int main(int argc, char **argv) +{ + QCoreApplication app(argc, argv); + return app.exec(); +} diff --git a/Tests/RunCMake/add_dependencies/CMakeLists.txt b/Tests/RunCMake/add_dependencies/CMakeLists.txt new file mode 100644 index 000000000..e8db6b05b --- /dev/null +++ b/Tests/RunCMake/add_dependencies/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/add_dependencies/NoTarget-result.txt b/Tests/RunCMake/add_dependencies/NoTarget-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/add_dependencies/NoTarget-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/add_dependencies/NoTarget-stderr.txt b/Tests/RunCMake/add_dependencies/NoTarget-stderr.txt new file mode 100644 index 000000000..6af27074f --- /dev/null +++ b/Tests/RunCMake/add_dependencies/NoTarget-stderr.txt @@ -0,0 +1,9 @@ +CMake Error at NoTarget.cmake:1 \(add_dependencies\): + Cannot add target-level dependencies to non-existent target "foo". + + The add_dependencies works for top-level logical targets created by the + add_executable, add_library, or add_custom_target commands. If you want to + add file-level dependencies see the DEPENDS option of the add_custom_target + and add_custom_command commands. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/add_dependencies/NoTarget.cmake b/Tests/RunCMake/add_dependencies/NoTarget.cmake new file mode 100644 index 000000000..903769417 --- /dev/null +++ b/Tests/RunCMake/add_dependencies/NoTarget.cmake @@ -0,0 +1 @@ +add_dependencies(foo bar) diff --git a/Tests/RunCMake/add_dependencies/RunCMakeTest.cmake b/Tests/RunCMake/add_dependencies/RunCMakeTest.cmake new file mode 100644 index 000000000..30b7e674f --- /dev/null +++ b/Tests/RunCMake/add_dependencies/RunCMakeTest.cmake @@ -0,0 +1,3 @@ +include(RunCMake) + +run_cmake(NoTarget) diff --git a/Tests/RunCMake/include_directories/BinaryDirectoryInInterface-result.txt b/Tests/RunCMake/include_directories/BinaryDirectoryInInterface-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/include_directories/BinaryDirectoryInInterface-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/include_directories/BinaryDirectoryInInterface-stderr.txt b/Tests/RunCMake/include_directories/BinaryDirectoryInInterface-stderr.txt new file mode 100644 index 000000000..0d4379eb0 --- /dev/null +++ b/Tests/RunCMake/include_directories/BinaryDirectoryInInterface-stderr.txt @@ -0,0 +1,6 @@ +CMake Error in CMakeLists.txt: + Target "testTarget" INTERFACE_INCLUDE_DIRECTORIES property contains path: + + ".*RunCMake/include_directories/BinaryDirectoryInInterface-build/foo" + + which is prefixed in the build directory. diff --git a/Tests/RunCMake/include_directories/BinaryDirectoryInInterface.cmake b/Tests/RunCMake/include_directories/BinaryDirectoryInInterface.cmake new file mode 100644 index 000000000..875454029 --- /dev/null +++ b/Tests/RunCMake/include_directories/BinaryDirectoryInInterface.cmake @@ -0,0 +1,11 @@ + +project(BinaryDirectoryInInterface) + +add_library(testTarget "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp") +target_include_directories(testTarget INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/foo") + +install(TARGETS testTarget EXPORT testTargets + DESTINATION lib +) + +install(EXPORT testTargets DESTINATION lib/cmake) diff --git a/Tests/RunCMake/include_directories/ImportedTarget-result.txt b/Tests/RunCMake/include_directories/ImportedTarget-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/include_directories/ImportedTarget-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/include_directories/ImportedTarget-stderr.txt b/Tests/RunCMake/include_directories/ImportedTarget-stderr.txt new file mode 100644 index 000000000..da2605297 --- /dev/null +++ b/Tests/RunCMake/include_directories/ImportedTarget-stderr.txt @@ -0,0 +1,13 @@ +CMake Error in CMakeLists.txt: + Imported target "imported" includes non-existent path + + "/does/not/exist" + + in its INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include: + + \* The path was deleted, renamed, or moved to another location. + + \* An install or uninstall procedure did not complete successfully. + + \* The installation package was faulty and references files it does not + provide. diff --git a/Tests/RunCMake/include_directories/ImportedTarget.cmake b/Tests/RunCMake/include_directories/ImportedTarget.cmake new file mode 100644 index 000000000..e1a20b130 --- /dev/null +++ b/Tests/RunCMake/include_directories/ImportedTarget.cmake @@ -0,0 +1,9 @@ + +project(ImportedTarget) + +add_library(testTarget "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp") + +add_library(imported UNKNOWN IMPORTED) +set_property(TARGET imported PROPERTY INTERFACE_INCLUDE_DIRECTORIES "/does/not/exist") + +target_link_libraries(testTarget imported) diff --git a/Tests/RunCMake/include_directories/RelativePathInGenex-result.txt b/Tests/RunCMake/include_directories/RelativePathInGenex-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/include_directories/RelativePathInGenex-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/include_directories/RelativePathInGenex-stderr.txt b/Tests/RunCMake/include_directories/RelativePathInGenex-stderr.txt new file mode 100644 index 000000000..490c700f8 --- /dev/null +++ b/Tests/RunCMake/include_directories/RelativePathInGenex-stderr.txt @@ -0,0 +1,5 @@ +CMake Error in CMakeLists.txt: + Target "testTarget" contains relative path in its + INTERFACE_INCLUDE_DIRECTORIES: + + "foo" diff --git a/Tests/RunCMake/include_directories/RelativePathInGenex.cmake b/Tests/RunCMake/include_directories/RelativePathInGenex.cmake new file mode 100644 index 000000000..f72cf3adb --- /dev/null +++ b/Tests/RunCMake/include_directories/RelativePathInGenex.cmake @@ -0,0 +1,8 @@ + +project(RelativePathInInterface) + +add_library(testTarget "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp") +set_property(TARGET testTarget PROPERTY INTERFACE_INCLUDE_DIRECTORIES "$<1:foo>") + +add_library(userTarget "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp") +target_link_libraries(userTarget testTarget) diff --git a/Tests/RunCMake/include_directories/RelativePathInInterface-result.txt b/Tests/RunCMake/include_directories/RelativePathInInterface-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/include_directories/RelativePathInInterface-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/include_directories/RelativePathInInterface-stderr.txt b/Tests/RunCMake/include_directories/RelativePathInInterface-stderr.txt new file mode 100644 index 000000000..f6cdb532e --- /dev/null +++ b/Tests/RunCMake/include_directories/RelativePathInInterface-stderr.txt @@ -0,0 +1,5 @@ +CMake Error in CMakeLists.txt: + Target "testTarget" INTERFACE_INCLUDE_DIRECTORIES property contains + relative path: + + "foo" diff --git a/Tests/RunCMake/include_directories/RelativePathInInterface.cmake b/Tests/RunCMake/include_directories/RelativePathInInterface.cmake new file mode 100644 index 000000000..f2ce54ae2 --- /dev/null +++ b/Tests/RunCMake/include_directories/RelativePathInInterface.cmake @@ -0,0 +1,11 @@ + +project(RelativePathInInterface) + +add_library(testTarget "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp") +set_property(TARGET testTarget PROPERTY INTERFACE_INCLUDE_DIRECTORIES "foo") + +install(TARGETS testTarget EXPORT testTargets + DESTINATION lib +) + +install(EXPORT testTargets DESTINATION lib/cmake) diff --git a/Tests/RunCMake/include_directories/RunCMakeTest.cmake b/Tests/RunCMake/include_directories/RunCMakeTest.cmake index ddf268c1e..f5160860d 100644 --- a/Tests/RunCMake/include_directories/RunCMakeTest.cmake +++ b/Tests/RunCMake/include_directories/RunCMakeTest.cmake @@ -3,3 +3,8 @@ include(RunCMake) run_cmake(NotFoundContent) run_cmake(DebugIncludes) run_cmake(TID-bad-target) +run_cmake(SourceDirectoryInInterface) +run_cmake(BinaryDirectoryInInterface) +run_cmake(RelativePathInInterface) +run_cmake(ImportedTarget) +run_cmake(RelativePathInGenex) diff --git a/Tests/RunCMake/include_directories/SourceDirectoryInInterface-result.txt b/Tests/RunCMake/include_directories/SourceDirectoryInInterface-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/include_directories/SourceDirectoryInInterface-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/include_directories/SourceDirectoryInInterface-stderr.txt b/Tests/RunCMake/include_directories/SourceDirectoryInInterface-stderr.txt new file mode 100644 index 000000000..9346b994f --- /dev/null +++ b/Tests/RunCMake/include_directories/SourceDirectoryInInterface-stderr.txt @@ -0,0 +1,6 @@ +CMake Error in CMakeLists.txt: + Target "testTarget" INTERFACE_INCLUDE_DIRECTORIES property contains path: + + ".*RunCMake/include_directories/foo" + + which is prefixed in the source directory. diff --git a/Tests/RunCMake/include_directories/SourceDirectoryInInterface.cmake b/Tests/RunCMake/include_directories/SourceDirectoryInInterface.cmake new file mode 100644 index 000000000..c9a9c457b --- /dev/null +++ b/Tests/RunCMake/include_directories/SourceDirectoryInInterface.cmake @@ -0,0 +1,11 @@ + +project(SourceDirectoryInInterface) + +add_library(testTarget "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp") +target_include_directories(testTarget INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/foo") + +install(TARGETS testTarget EXPORT testTargets + DESTINATION lib +) + +install(EXPORT testTargets DESTINATION lib/cmake) diff --git a/Tests/RunCMake/include_directories/empty.cpp b/Tests/RunCMake/include_directories/empty.cpp new file mode 100644 index 000000000..e69de29bb