diff options
142 files changed, 1527 insertions, 654 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 7aa8010..bec81a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -510,6 +510,9 @@ int main(void) { return 0; } elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "sparc") # Disable until it can be ported. set(CMAKE_USE_LIBUV 0) + elseif(CMAKE_SYSTEM STREQUAL "SunOS-5.10") + # Disable until it can be ported. + set(CMAKE_USE_LIBUV 0) endif() endif() if(CMAKE_USE_LIBUV) diff --git a/Copyright.txt b/Copyright.txt index aa91102..daaa1d1 100644 --- a/Copyright.txt +++ b/Copyright.txt @@ -37,6 +37,7 @@ The following individuals and institutions are among the Contributors: * Aleksey Avdeev <solo@altlinux.ru> * Alexander Neundorf <neundorf@kde.org> * Alexander Smorkalov <alexander.smorkalov@itseez.com> +* Alexey Sokolov <sokolov@google.com> * Alex Turbov <i.zaufi@gmail.com> * Andreas Pakulat <apaku@gmx.de> * Andreas Schneider <asn@cryptomilk.org> @@ -54,6 +55,7 @@ The following individuals and institutions are among the Contributors: * Eran Ifrah <eran.ifrah@gmail.com> * Esben Mose Hansen, Ange Optimization ApS * Geoffrey Viola <geoffrey.viola@asirobots.com> +* Google Inc * Gregor Jasny * Helio Chissini de Castro <helio@kde.org> * Ilya Lavrenov <ilya.lavrenov@itseez.com> diff --git a/Help/generator/CodeBlocks.rst b/Help/generator/CodeBlocks.rst index 01798c7..d03cb0c 100644 --- a/Help/generator/CodeBlocks.rst +++ b/Help/generator/CodeBlocks.rst @@ -18,6 +18,9 @@ This "extra" generator may be specified as: ``CodeBlocks - NMake Makefiles`` Generate with :generator:`NMake Makefiles`. +``CodeBlocks - NMake Makefiles JOM`` + Generate with :generator:`NMake Makefiles JOM`. + ``CodeBlocks - Ninja`` Generate with :generator:`Ninja`. diff --git a/Help/manual/cmake-modules.7.rst b/Help/manual/cmake-modules.7.rst index 015e36e..d4712ba 100644 --- a/Help/manual/cmake-modules.7.rst +++ b/Help/manual/cmake-modules.7.rst @@ -59,6 +59,7 @@ All Modules /module/CPackDeb /module/CPackDMG /module/CPackIFW + /module/CPackIFWConfigureFile /module/CPackNSIS /module/CPackPackageMaker /module/CPackProductBuild diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index 971834e..c93ace1 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -357,6 +357,10 @@ Properties on Source Files /prop_sf/MACOSX_PACKAGE_LOCATION /prop_sf/OBJECT_DEPENDS /prop_sf/OBJECT_OUTPUTS + /prop_sf/SKIP_AUTOGEN + /prop_sf/SKIP_AUTOMOC + /prop_sf/SKIP_AUTORCC + /prop_sf/SKIP_AUTOUIC /prop_sf/SYMBOLIC /prop_sf/VS_DEPLOYMENT_CONTENT /prop_sf/VS_DEPLOYMENT_LOCATION diff --git a/Help/manual/cmake-qt.7.rst b/Help/manual/cmake-qt.7.rst index 80b0f49..56d4ca7 100644 --- a/Help/manual/cmake-qt.7.rst +++ b/Help/manual/cmake-qt.7.rst @@ -83,6 +83,9 @@ following targets by setting the :variable:`CMAKE_AUTOMOC` variable. The options to pass to ``moc``. The :variable:`CMAKE_AUTOMOC_MOC_OPTIONS` variable may be populated to pre-set the options for all following targets. +Source C++ files can be excluded from :prop_tgt:`AUTOMOC` processing by +enabling :prop_sf:`SKIP_AUTOMOC` or the broader :prop_sf:`SKIP_AUTOGEN`. + .. _`Qt AUTOUIC`: AUTOUIC @@ -149,6 +152,9 @@ result of linking with the :prop_tgt:`IMPORTED` target: Qt5::Widgets ) +Source files can be excluded from :prop_tgt:`AUTOUIC` processing by +enabling :prop_sf:`SKIP_AUTOUIC` or the broader :prop_sf:`SKIP_AUTOGEN`. + .. _`Qt AUTORCC`: AUTORCC @@ -171,6 +177,9 @@ populated to pre-set the options for all following targets. The ``<name>.qrc`` file to set particular options for the file. This overrides options from the :prop_tgt:`AUTORCC_OPTIONS` target property. +Source files can be excluded from :prop_tgt:`AUTORCC` processing by +enabling :prop_sf:`SKIP_AUTORCC` or the broader :prop_sf:`SKIP_AUTOGEN`. + qtmain.lib on Windows ===================== diff --git a/Help/module/CPackIFWConfigureFile.rst b/Help/module/CPackIFWConfigureFile.rst new file mode 100644 index 0000000..e88517c --- /dev/null +++ b/Help/module/CPackIFWConfigureFile.rst @@ -0,0 +1 @@ +.. cmake-module:: ../../Modules/CPackIFWConfigureFile.cmake diff --git a/Help/prop_sf/SKIP_AUTOGEN.rst b/Help/prop_sf/SKIP_AUTOGEN.rst new file mode 100644 index 0000000..6bf2409 --- /dev/null +++ b/Help/prop_sf/SKIP_AUTOGEN.rst @@ -0,0 +1,8 @@ +SKIP_AUTOGEN +------------ + +Exclude the source file from :prop_tgt:`AUTOMOC`, :prop_tgt:`AUTOUIC` and +:prop_tgt:`AUTORCC` processing (for Qt projects). + +For finer control see :prop_sf:`SKIP_AUTOMOC`, :prop_sf:`SKIP_AUTOUIC` and +:prop_sf:`SKIP_AUTORCC`. diff --git a/Help/prop_sf/SKIP_AUTOMOC.rst b/Help/prop_sf/SKIP_AUTOMOC.rst new file mode 100644 index 0000000..2245ca6 --- /dev/null +++ b/Help/prop_sf/SKIP_AUTOMOC.rst @@ -0,0 +1,6 @@ +SKIP_AUTOMOC +------------ + +Exclude the source file from :prop_tgt:`AUTOMOC` processing (for Qt projects). + +For broader control see :prop_sf:`SKIP_AUTOGEN` diff --git a/Help/prop_sf/SKIP_AUTORCC.rst b/Help/prop_sf/SKIP_AUTORCC.rst new file mode 100644 index 0000000..394d8f8 --- /dev/null +++ b/Help/prop_sf/SKIP_AUTORCC.rst @@ -0,0 +1,6 @@ +SKIP_AUTORCC +------------ + +Exclude the source file from :prop_tgt:`AUTORCC` processing (for Qt projects). + +For broader control see :prop_sf:`SKIP_AUTOGEN` diff --git a/Help/prop_sf/SKIP_AUTOUIC.rst b/Help/prop_sf/SKIP_AUTOUIC.rst new file mode 100644 index 0000000..50f78ef --- /dev/null +++ b/Help/prop_sf/SKIP_AUTOUIC.rst @@ -0,0 +1,6 @@ +SKIP_AUTOUIC +------------ + +Exclude the source file from :prop_tgt:`AUTOUIC` processing (for Qt projects). + +For broader control see :prop_sf:`SKIP_AUTOGEN` diff --git a/Help/prop_tgt/AUTOMOC.rst b/Help/prop_tgt/AUTOMOC.rst index 30a39b1..b42643f 100644 --- a/Help/prop_tgt/AUTOMOC.rst +++ b/Help/prop_tgt/AUTOMOC.rst @@ -47,5 +47,8 @@ See the documentation for this variable for more details. The global property :prop_gbl:`AUTOGEN_TARGETS_FOLDER` can be used to group the automoc targets together in an IDE, e.g. in MSVS. +Source C++ files can be excluded from :prop_tgt:`AUTOMOC` processing by +enabling :prop_sf:`SKIP_AUTOMOC` or the broader :prop_sf:`SKIP_AUTOGEN`. + See the :manual:`cmake-qt(7)` manual for more information on using CMake with Qt. diff --git a/Help/prop_tgt/AUTORCC.rst b/Help/prop_tgt/AUTORCC.rst index 158fdf8..1ad0895 100644 --- a/Help/prop_tgt/AUTORCC.rst +++ b/Help/prop_tgt/AUTORCC.rst @@ -24,5 +24,8 @@ generate unspecified unique names for ``rcc``. Therefore if ``Q_INIT_RESOURCE()`` or ``Q_CLEANUP_RESOURCE()`` need to be used the ``.qrc`` file name must be unique. +Source files can be excluded from :prop_tgt:`AUTORCC` processing by +enabling :prop_sf:`SKIP_AUTORCC` or the broader :prop_sf:`SKIP_AUTOGEN`. + See the :manual:`cmake-qt(7)` manual for more information on using CMake with Qt. diff --git a/Help/prop_tgt/AUTOUIC.rst b/Help/prop_tgt/AUTOUIC.rst index 4e60ec3..fbf24c3 100644 --- a/Help/prop_tgt/AUTOUIC.rst +++ b/Help/prop_tgt/AUTOUIC.rst @@ -20,5 +20,8 @@ Additional command line options for ``uic`` can be set via the The global property :prop_gbl:`AUTOGEN_TARGETS_FOLDER` can be used to group the autouic targets together in an IDE, e.g. in MSVS. +Source files can be excluded from :prop_tgt:`AUTOUIC` processing by +enabling :prop_sf:`SKIP_AUTOUIC` or the broader :prop_sf:`SKIP_AUTOGEN`. + See the :manual:`cmake-qt(7)` manual for more information on using CMake with Qt. diff --git a/Help/release/dev/QtAutogen_Skip.rst b/Help/release/dev/QtAutogen_Skip.rst new file mode 100644 index 0000000..37f795c --- /dev/null +++ b/Help/release/dev/QtAutogen_Skip.rst @@ -0,0 +1,12 @@ +QtAutogen_Skip +-------------- + +* The source file properties + :prop_sf:`SKIP_AUTOMOC`, + :prop_sf:`SKIP_AUTOUIC`, + :prop_sf:`SKIP_AUTORCC` and + :prop_sf:`SKIP_AUTOGEN` + allow to exclude files from + :prop_tgt:`AUTOMOC`, + :prop_tgt:`AUTOUIC` and + :prop_tgt:`AUTORCC` processing. diff --git a/Help/release/dev/SublimeText-no-VERBOSE.rst b/Help/release/dev/SublimeText-no-VERBOSE.rst new file mode 100644 index 0000000..70dfa2b --- /dev/null +++ b/Help/release/dev/SublimeText-no-VERBOSE.rst @@ -0,0 +1,6 @@ +SublimeText-no-VERBOSE +---------------------- + +* The :generator:`Sublime Text 2` generator no longer runs the native + build command (e.g. ``ninja`` or ``make``) with verbose build output + enabled. diff --git a/Help/release/dev/codeblocks-nmake-makefiles-jom.rst b/Help/release/dev/codeblocks-nmake-makefiles-jom.rst new file mode 100644 index 0000000..f5612f0 --- /dev/null +++ b/Help/release/dev/codeblocks-nmake-makefiles-jom.rst @@ -0,0 +1,5 @@ +codeblocks-nmake-makefiles-jom +------------------------------ + +* The :generator:`CodeBlocks` now can generate with + :generator:`NMake Makefiles JOM`. diff --git a/Help/release/dev/cpack-ifw-configure-file.rst b/Help/release/dev/cpack-ifw-configure-file.rst new file mode 100644 index 0000000..c9a1220 --- /dev/null +++ b/Help/release/dev/cpack-ifw-configure-file.rst @@ -0,0 +1,9 @@ +cpack-ifw-configure-file +------------------------ + +* The :command:`cpack_ifw_configure_file` command was added + (in :module:`CPackIFWConfigureFile`) to configure file templates prepared + in QtIFW/SDK/Creator style. + +* The :module:`CPackIFWConfigureFile` module was added to define + :command:`cpack_ifw_configure_file` command. diff --git a/Help/release/dev/ctest_memcheck-leak_sanitizer.rst b/Help/release/dev/ctest_memcheck-leak_sanitizer.rst new file mode 100644 index 0000000..3fa5c49 --- /dev/null +++ b/Help/release/dev/ctest_memcheck-leak_sanitizer.rst @@ -0,0 +1,19 @@ +ctest_memcheck-leak_sanitizer +============================= + +* The :command:`ctest_memcheck` command learned to support ``LeakSanitizer`` + independently from ``AddressSanitizer``. + +* The :command:`ctest_memcheck` command no longer automatically adds + ``leak_check=1`` to the options used by ``AddressSanitizer``. The default + behavior of ``AddressSanitizer`` is to run `LeakSanitizer` to check leaks + unless ``leak_check=0``. + +* The :command:`ctest_memcheck` command learned to read the location of + suppressions files for sanitizers from the + :variable:`CTEST_MEMORYCHECK_SUPPRESSIONS_FILE` variable. + +* The :command:`ctest_memcheck` command was fixed to correctly append extra + sanitizer options read from the + :variable:`CTEST_MEMORYCHECK_SANITIZER_OPTIONS` variable to the environment + variables used internally by the sanitizers. diff --git a/Help/variable/CTEST_MEMORYCHECK_TYPE.rst b/Help/variable/CTEST_MEMORYCHECK_TYPE.rst index b963293..b8b4c30 100644 --- a/Help/variable/CTEST_MEMORYCHECK_TYPE.rst +++ b/Help/variable/CTEST_MEMORYCHECK_TYPE.rst @@ -4,5 +4,5 @@ CTEST_MEMORYCHECK_TYPE Specify the CTest ``MemoryCheckType`` setting in a :manual:`ctest(1)` dashboard client script. Valid values are ``Valgrind``, ``Purify``, ``BoundsChecker``, and -``ThreadSanitizer``, ``AddressSanitizer``, ``MemorySanitizer``, and +``ThreadSanitizer``, ``AddressSanitizer``, ``LeakSanitizer``, ``MemorySanitizer``, and ``UndefinedBehaviorSanitizer``. diff --git a/Modules/AndroidTestUtilities/PushToAndroidDevice.cmake b/Modules/AndroidTestUtilities/PushToAndroidDevice.cmake index f5f2564..d8ca730 100644 --- a/Modules/AndroidTestUtilities/PushToAndroidDevice.cmake +++ b/Modules/AndroidTestUtilities/PushToAndroidDevice.cmake @@ -117,7 +117,7 @@ function(android_push_test_files_to_device) check_device_file_exists(${_ptd_DEV_TEST_DIR} test_dir_exists) if(test_dir_exists) # This is protected in the SetupProjectTests module. - execute_adb_command(shell echo rm -r ${_ptd_DEV_TEST_DIR} | su) + execute_adb_command(shell rm -r ${_ptd_DEV_TEST_DIR}) endif() execute_adb_command(shell mkdir -p ${_ptd_DEV_TEST_DIR}) diff --git a/Modules/AutogenInfo.cmake.in b/Modules/AutogenInfo.cmake.in index 84b0f4d..3fafaff 100644 --- a/Modules/AutogenInfo.cmake.in +++ b/Modules/AutogenInfo.cmake.in @@ -1,7 +1,7 @@ -set(AM_SOURCES @_cpp_files@ ) -set(AM_SKIP_MOC @_skip_moc@ ) -set(AM_SKIP_UIC @_skip_uic@ ) -set(AM_HEADERS @_moc_headers@ ) +set(AM_SOURCES @_moc_uic_sources@) +set(AM_HEADERS @_moc_uic_headers@) +set(AM_SKIP_MOC @_skip_moc@) +set(AM_SKIP_UIC @_skip_uic@) set(AM_MOC_COMPILE_DEFINITIONS @_moc_compile_defs@) set(AM_MOC_INCLUDES @_moc_incs@) set(AM_MOC_OPTIONS @_moc_options@) diff --git a/Modules/BundleUtilities.cmake b/Modules/BundleUtilities.cmake index b1610e2..5d6f402 100644 --- a/Modules/BundleUtilities.cmake +++ b/Modules/BundleUtilities.cmake @@ -624,6 +624,33 @@ function(get_bundle_keys app libs dirs keys_var) endif() endforeach() + # preserve library symlink structure + foreach(key ${${keys_var}}) + if("${${key}_COPYFLAG}" STREQUAL 1) + if(IS_SYMLINK "${${key}_RESOLVED_ITEM}") + get_filename_component(target "${${key}_RESOLVED_ITEM}" REALPATH) + set_bundle_key_values(${keys_var} "${exe}" "${target}" "${exepath}" "${dirs}" 1 "${exe_rpaths}") + get_item_key("${target}" targetkey) + + if(WIN32) + # ignore case on Windows + string(TOLOWER "${${key}_RESOLVED_ITEM}" resolved_item_compare) + string(TOLOWER "${${targetkey}_RESOLVED_EMBEDDED_ITEM}" resolved_embedded_item_compare) + else() + set(resolved_item_compare "${${key}_RESOLVED_ITEM}") + set(resolved_embedded_item_compare "${${targetkey}_RESOLVED_EMBEDDED_ITEM}") + endif() + get_filename_component(resolved_item_compare "${resolved_item_compare}" NAME) + get_filename_component(resolved_embedded_item_compare "${resolved_embedded_item_compare}" NAME) + + if(NOT "${resolved_item_compare}" STREQUAL "${resolved_embedded_item_compare}") + set(${key}_COPYFLAG "2") + set(${key}_RESOLVED_ITEM "${${targetkey}_RESOLVED_EMBEDDED_ITEM}") + endif() + + endif() + endif() + endforeach() # Propagate values to caller's scope: # set(${keys_var} ${${keys_var}} PARENT_SCOPE) @@ -640,6 +667,24 @@ function(get_bundle_keys app libs dirs keys_var) endif() endfunction() +function(link_resolved_item_into_bundle resolved_item resolved_embedded_item) + if(WIN32) + # ignore case on Windows + string(TOLOWER "${resolved_item}" resolved_item_compare) + string(TOLOWER "${resolved_embedded_item}" resolved_embedded_item_compare) + else() + set(resolved_item_compare "${resolved_item}") + set(resolved_embedded_item_compare "${resolved_embedded_item}") + endif() + + if("${resolved_item_compare}" STREQUAL "${resolved_embedded_item_compare}") + message(STATUS "warning: resolved_item == resolved_embedded_item - not linking...") + else() + get_filename_component(target_dir "${resolved_embedded_item}" DIRECTORY) + file(RELATIVE_PATH symlink_target "${target_dir}" "${resolved_item}") + execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${symlink_target}" "${resolved_embedded_item}") + endif() +endfunction() function(copy_resolved_item_into_bundle resolved_item resolved_embedded_item) if(WIN32) @@ -854,7 +899,9 @@ function(fixup_bundle app libs dirs) set(i 0) foreach(key ${keys}) math(EXPR i ${i}+1) - if(${${key}_COPYFLAG}) + if("${${key}_COPYFLAG}" STREQUAL "2") + message(STATUS "${i}/${n}: linking '${${key}_RESOLVED_ITEM}' -> '${${key}_RESOLVED_EMBEDDED_ITEM}'") + elseif(${${key}_COPYFLAG}) message(STATUS "${i}/${n}: copying '${${key}_RESOLVED_ITEM}'") else() message(STATUS "${i}/${n}: *NOT* copying '${${key}_RESOLVED_ITEM}'") @@ -872,7 +919,10 @@ function(fixup_bundle app libs dirs) message(STATUS "") endif() - if(${${key}_COPYFLAG}) + if("${${key}_COPYFLAG}" STREQUAL "2") + link_resolved_item_into_bundle("${${key}_RESOLVED_ITEM}" + "${${key}_RESOLVED_EMBEDDED_ITEM}") + elseif(${${key}_COPYFLAG}) set(item "${${key}_ITEM}") if(item MATCHES "[^/]+\\.framework/") copy_resolved_framework_into_bundle("${${key}_RESOLVED_ITEM}" @@ -889,7 +939,9 @@ function(fixup_bundle app libs dirs) math(EXPR i ${i}+1) if(APPLE) message(STATUS "${i}/${n}: fixing up '${${key}_RESOLVED_EMBEDDED_ITEM}'") - fixup_bundle_item("${${key}_RESOLVED_EMBEDDED_ITEM}" "${exepath}" "${dirs}") + if(NOT "${${key}_COPYFLAG}" STREQUAL "2") + fixup_bundle_item("${${key}_RESOLVED_EMBEDDED_ITEM}" "${exepath}" "${dirs}") + endif() else() message(STATUS "${i}/${n}: fix-up not required on this platform '${${key}_RESOLVED_EMBEDDED_ITEM}'") endif() diff --git a/Modules/CMakeAddFortranSubdirectory.cmake b/Modules/CMakeAddFortranSubdirectory.cmake index 3b39bce..4649f35 100644 --- a/Modules/CMakeAddFortranSubdirectory.cmake +++ b/Modules/CMakeAddFortranSubdirectory.cmake @@ -45,7 +45,6 @@ set(_MS_MINGW_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}) include(CheckLanguage) include(ExternalProject) -include(CMakeParseArguments) function(_setup_mingw_config_and_build source_dir build_dir) # Look for a MinGW gfortran. diff --git a/Modules/CMakeCompilerIdDetection.cmake b/Modules/CMakeCompilerIdDetection.cmake index 484e1f0..7ca79bd 100644 --- a/Modules/CMakeCompilerIdDetection.cmake +++ b/Modules/CMakeCompilerIdDetection.cmake @@ -11,8 +11,6 @@ function(_readFile file) set(_compiler_id_pp_test_${CompilerId} ${_compiler_id_pp_test} PARENT_SCOPE) endfunction() -include(${CMAKE_CURRENT_LIST_DIR}/CMakeParseArguments.cmake) - function(compiler_id_detection outvar lang) if (NOT lang STREQUAL Fortran AND NOT lang STREQUAL CSharp) diff --git a/Modules/CMakeExpandImportedTargets.cmake b/Modules/CMakeExpandImportedTargets.cmake index add0c6d..ad065f0 100644 --- a/Modules/CMakeExpandImportedTargets.cmake +++ b/Modules/CMakeExpandImportedTargets.cmake @@ -37,9 +37,6 @@ # LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} # CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}" ) - -include(${CMAKE_CURRENT_LIST_DIR}/CMakeParseArguments.cmake) - function(CMAKE_EXPAND_IMPORTED_TARGETS _RESULT ) set(options ) diff --git a/Modules/CMakePackageConfigHelpers.cmake b/Modules/CMakePackageConfigHelpers.cmake index 8415641..3210222 100644 --- a/Modules/CMakePackageConfigHelpers.cmake +++ b/Modules/CMakePackageConfigHelpers.cmake @@ -201,9 +201,6 @@ # # check_required_components(Foo) - -include(CMakeParseArguments) - include(WriteBasicConfigVersionFile) macro(WRITE_BASIC_PACKAGE_VERSION_FILE) diff --git a/Modules/CMakePrintHelpers.cmake b/Modules/CMakePrintHelpers.cmake index bf98a42..21c333e 100644 --- a/Modules/CMakePrintHelpers.cmake +++ b/Modules/CMakePrintHelpers.cmake @@ -39,8 +39,6 @@ # # -- CMAKE_C_COMPILER="/usr/bin/gcc" ; CMAKE_MAJOR_VERSION="2" ; DOES_NOT_EXIST="" -include(CMakeParseArguments) - function(CMAKE_PRINT_VARIABLES) set(msg "") foreach(var ${ARGN}) diff --git a/Modules/CPackDeb.cmake b/Modules/CPackDeb.cmake index bee69d9..ddf8b23 100644 --- a/Modules/CPackDeb.cmake +++ b/Modules/CPackDeb.cmake @@ -914,7 +914,7 @@ function(cpack_deb_prepare_package_vars) extract_so_info("${_FILE}" libname soversion) if(libname AND soversion) list(APPEND CPACK_DEBIAN_PACKAGE_SHLIBS_LIST - "${libname} ${soversion} ${CPACK_DEBIAN_PACKAGE_NAME} (${CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY} ${CPACK_PACKAGE_VERSION})") + "${libname} ${soversion} ${CPACK_DEBIAN_PACKAGE_NAME} (${CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY} ${CPACK_DEBIAN_PACKAGE_VERSION})") else() message(AUTHOR_WARNING "Shared library '${_FILE}' is missing soname or soversion. Library will not be added to DEBIAN/shlibs control file.") endif() @@ -967,7 +967,7 @@ function(cpack_deb_prepare_package_vars) # Patch package file name to be in corrent debian format: # <foo>_<VersionNumber>-<DebianRevisionNumber>_<DebianArchitecture>.deb set(CPACK_OUTPUT_FILE_NAME - "${CPACK_DEBIAN_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb") + "${CPACK_DEBIAN_PACKAGE_NAME}_${CPACK_DEBIAN_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb") else() cmake_policy(PUSH) cmake_policy(SET CMP0010 NEW) diff --git a/Modules/CPackIFW.cmake b/Modules/CPackIFW.cmake index d0d24ba..b3ab055 100644 --- a/Modules/CPackIFW.cmake +++ b/Modules/CPackIFW.cmake @@ -630,10 +630,6 @@ if(NOT CPackComponent_CMake_INCLUDED) include(CPackComponent) endif() -if(NOT __CMAKE_PARSE_ARGUMENTS_INCLUDED) - include(CMakeParseArguments) -endif() - # Resolve full filename for script file macro(_cpack_ifw_resolve_script _variable) set(_ifw_script_macro ${_variable}) diff --git a/Modules/CPackIFWConfigureFile.cmake b/Modules/CPackIFWConfigureFile.cmake new file mode 100644 index 0000000..790574a --- /dev/null +++ b/Modules/CPackIFWConfigureFile.cmake @@ -0,0 +1,65 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#.rst: +# CPackIFWConfigureFile +# --------------------- +# +# The module defines :command:`configure_file` similar command to +# configure file templates prepared in QtIFW/SDK/Creator style. +# +# +# Commands +# ^^^^^^^^ +# +# The module defines the following commands: +# +# .. command:: cpack_ifw_configure_file +# +# Copy a file to another location and modify its contents. +# +# :: +# +# cpack_ifw_configure_file(<input> <output>) +# +# Copies an ``<input>`` file to an ``<output>`` file and substitutes variable +# values referenced as ``%{VAR}`` or ``%VAR%`` in the input file content. +# Each variable reference will be replaced with the current value of the +# variable, or the empty string if the variable is not defined. +# + +# NOTE: This file used to himself packaging via CPack IFW generator and +# should be compatible with minimal CMake version defined in +# ../CMakeLists.txt file. + +if(NOT DEFINED CPackIFWConfigureFile_CMake_INCLUDED) +set(CPackIFWConfigureFile_CMake_INCLUDED 1) + +macro(cpack_ifw_configure_file INPUT OUTPUT) + file(READ "${INPUT}" _tmp) + foreach(_tmp_regex "%{([^%}]+)}" "%([^%]+)%") + string(REGEX MATCHALL "${_tmp_regex}" _tmp_vars "${_tmp}") + while(_tmp_vars) + foreach(_tmp_var ${_tmp_vars}) + string(REGEX REPLACE "${_tmp_regex}" "\\1" + _tmp_var_name "${_tmp_var}") + if(DEFINED ${_tmp_var_name}) + set(_tmp_var_value "${${_tmp_var_name}}") + elseif(NOT "$ENV{${_tmp_var_name}}" STREQUAL "") + set(_tmp_var_value "$ENV{${_tmp_var_name}}") + else() + set(_tmp_var_value "") + endif() + string(REPLACE "${_tmp_var}" "${_tmp_var_value}" _tmp "${_tmp}") + endforeach() + string(REGEX MATCHALL "${_tmp_regex}" _tmp_vars "${_tmp}") + endwhile() + endforeach() + if(IS_ABSOLUTE "${OUTPUT}") + file(WRITE "${OUTPUT}" "${_tmp}") + else() + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT}" "${_tmp}") + endif() +endmacro() + +endif() # NOT DEFINED CPackIFWConfigureFile_CMake_INCLUDED diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index 5021c41..722ee15 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -2473,8 +2473,8 @@ Vendor: \@CPACK_RPM_PACKAGE_VENDOR\@ # We should generate a USER spec file template: # - either because the user asked for it : CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE # - or the user did not provide one : NOT CPACK_RPM_USER_BINARY_SPECFILE + set(RPMBUILD_FLAGS "-bb") if(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE OR NOT CPACK_RPM_USER_BINARY_SPECFILE) - set(RPMBUILD_FLAGS "-bb") file(WRITE ${CPACK_RPM_BINARY_SPECFILE}.in "# -*- rpm-spec -*- diff --git a/Modules/CTestCoverageCollectGCOV.cmake b/Modules/CTestCoverageCollectGCOV.cmake index 8451a6a..1203be4 100644 --- a/Modules/CTestCoverageCollectGCOV.cmake +++ b/Modules/CTestCoverageCollectGCOV.cmake @@ -65,7 +65,6 @@ # Suppress non-error messages that otherwise would have been # printed out by this function. -include(CMakeParseArguments) function(ctest_coverage_collect_gcov) set(options QUIET GLOB DELETE) set(oneValueArgs TARBALL SOURCE BUILD GCOV_COMMAND) diff --git a/Modules/Compiler/PGI-Fortran.cmake b/Modules/Compiler/PGI-Fortran.cmake index 3765079..4783424 100644 --- a/Modules/Compiler/PGI-Fortran.cmake +++ b/Modules/Compiler/PGI-Fortran.cmake @@ -1,6 +1,9 @@ include(Compiler/PGI) __compiler_pgi(Fortran) +set(CMAKE_Fortran_PREPROCESS_SOURCE + "<CMAKE_Fortran_COMPILER> -Mpreprocess <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") + set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-Mnofreeform") set(CMAKE_Fortran_FORMAT_FREE_FLAG "-Mfreeform") diff --git a/Modules/FeatureSummary.cmake b/Modules/FeatureSummary.cmake index 88bc1c8..78d9df3 100644 --- a/Modules/FeatureSummary.cmake +++ b/Modules/FeatureSummary.cmake @@ -26,9 +26,6 @@ Functions #]=======================================================================] -include("${CMAKE_CURRENT_LIST_DIR}/CMakeParseArguments.cmake") - - function(_FS_GET_FEATURE_SUMMARY _property _var _includeQuiet) set(_type "ANY") diff --git a/Modules/FindBISON.cmake b/Modules/FindBISON.cmake index 0ebd465..d684ccd 100644 --- a/Modules/FindBISON.cmake +++ b/Modules/FindBISON.cmake @@ -84,8 +84,6 @@ find_program(BISON_EXECUTABLE NAMES bison win_bison DOC "path to the bison executable") mark_as_advanced(BISON_EXECUTABLE) -include(CMakeParseArguments) - if(BISON_EXECUTABLE) # the bison commands should be executed with the C locale, otherwise # the message (which are parsed) may be translated diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index e6bf3dc..266d135 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -742,6 +742,21 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) + elseif(NOT Boost_VERSION VERSION_LESS 106300 AND Boost_VERSION VERSION_LESS 106400) + set(_Boost_CHRONO_DEPENDENCIES system) + set(_Boost_CONTEXT_DEPENDENCIES thread chrono system date_time) + set(_Boost_COROUTINE_DEPENDENCIES context system) + set(_Boost_FIBER_DEPENDENCIES context thread chrono system date_time) + set(_Boost_FILESYSTEM_DEPENDENCIES system) + set(_Boost_IOSTREAMS_DEPENDENCIES regex) + set(_Boost_LOG_DEPENDENCIES date_time log_setup system filesystem thread regex chrono atomic) + set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic) + set(_Boost_MPI_DEPENDENCIES serialization) + set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization) + set(_Boost_RANDOM_DEPENDENCIES system) + set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic) + set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) + set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) else() message(WARNING "Imported targets not available for Boost version ${Boost_VERSION}") set(_Boost_IMPORTED_TARGETS FALSE) @@ -877,7 +892,7 @@ endfunction() # This function would append corresponding directories if MSVC is a current compiler, # so having `BOOST_ROOT` would be enough to specify to find everything. # -macro(_Boost_UPDATE_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS componentlibvar basedir) +macro(_Boost_UPDATE_WINDOWS_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS componentlibvar basedir) if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC") if(CMAKE_SIZEOF_VOID_P EQUAL 8) set(_arch_suffix 64) @@ -885,19 +900,19 @@ macro(_Boost_UPDATE_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS componentlibvar base set(_arch_suffix 32) endif() if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.10) - list(APPEND ${componentlibvar} ${${basedir}}/lib${_arch_suffix}-msvc-15.0) + list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-15.0) elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19) - list(APPEND ${componentlibvar} ${${basedir}}/lib${_arch_suffix}-msvc-14.0) + list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-14.0) elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18) - list(APPEND ${componentlibvar} ${${basedir}}/lib${_arch_suffix}-msvc-12.0) + list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-12.0) elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17) - list(APPEND ${componentlibvar} ${${basedir}}/lib${_arch_suffix}-msvc-11.0) + list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-11.0) elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16) - list(APPEND ${componentlibvar} ${${basedir}}/lib${_arch_suffix}-msvc-10.0) + list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-10.0) elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15) - list(APPEND ${componentlibvar} ${${basedir}}/lib${_arch_suffix}-msvc-9.0) + list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-9.0) elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14) - list(APPEND ${componentlibvar} ${${basedir}}/lib${_arch_suffix}-msvc-8.0) + list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-8.0) endif() endif() endmacro() @@ -948,7 +963,7 @@ else() # _Boost_COMPONENT_HEADERS. See the instructions at the top of # _Boost_COMPONENT_DEPENDENCIES. set(_Boost_KNOWN_VERSIONS ${Boost_ADDITIONAL_VERSIONS} - "1.62.0" "1.62" "1.61.0" "1.61" "1.60.0" "1.60" + "1.63.0" "1.63" "1.62.0" "1.62" "1.61.0" "1.61" "1.60.0" "1.60" "1.59.0" "1.59" "1.58.0" "1.58" "1.57.0" "1.57" "1.56.0" "1.56" "1.55.0" "1.55" "1.54.0" "1.54" "1.53.0" "1.53" "1.52.0" "1.52" "1.51.0" "1.51" "1.50.0" "1.50" "1.49.0" "1.49" "1.48.0" "1.48" "1.47.0" "1.47" "1.46.1" @@ -1361,10 +1376,10 @@ foreach(c DEBUG RELEASE) if(BOOST_ROOT) list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} ${BOOST_ROOT}/lib ${BOOST_ROOT}/stage/lib) - _Boost_UPDATE_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS(_boost_LIBRARY_SEARCH_DIRS_${c} BOOST_ROOT) + _Boost_UPDATE_WINDOWS_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS(_boost_LIBRARY_SEARCH_DIRS_${c} "${BOOST_ROOT}") elseif(_ENV_BOOST_ROOT) list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} ${_ENV_BOOST_ROOT}/lib ${_ENV_BOOST_ROOT}/stage/lib) - _Boost_UPDATE_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS(_boost_LIBRARY_SEARCH_DIRS_${c} _ENV_BOOST_ROOT) + _Boost_UPDATE_WINDOWS_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS(_boost_LIBRARY_SEARCH_DIRS_${c} "${_ENV_BOOST_ROOT}") endif() list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} @@ -1372,6 +1387,7 @@ foreach(c DEBUG RELEASE) ${Boost_INCLUDE_DIR}/../lib ${Boost_INCLUDE_DIR}/stage/lib ) + _Boost_UPDATE_WINDOWS_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS(_boost_LIBRARY_SEARCH_DIRS_${c} "${Boost_INCLUDE_DIR}/..") if( Boost_NO_SYSTEM_PATHS ) list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} NO_CMAKE_SYSTEM_PATH NO_SYSTEM_ENVIRONMENT_PATH) else() @@ -1380,6 +1396,7 @@ foreach(c DEBUG RELEASE) C:/boost /sw/local/lib ) + _Boost_UPDATE_WINDOWS_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS(_boost_LIBRARY_SEARCH_DIRS_${c} "C:/boost") endif() endif() endforeach() diff --git a/Modules/FindFLEX.cmake b/Modules/FindFLEX.cmake index 214873c..fef7fb4 100644 --- a/Modules/FindFLEX.cmake +++ b/Modules/FindFLEX.cmake @@ -107,8 +107,6 @@ find_path(FLEX_INCLUDE_DIR FlexLexer.h mark_as_advanced(FL_LIBRARY FLEX_INCLUDE_DIR) -include(${CMAKE_CURRENT_LIST_DIR}/CMakeParseArguments.cmake) - set(FLEX_INCLUDE_DIRS ${FLEX_INCLUDE_DIR}) set(FLEX_LIBRARIES ${FL_LIBRARY}) diff --git a/Modules/FindGTK2.cmake b/Modules/FindGTK2.cmake index 1f447f1..e1b22b6 100644 --- a/Modules/FindGTK2.cmake +++ b/Modules/FindGTK2.cmake @@ -165,7 +165,6 @@ #============================================================= include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/CMakeParseArguments.cmake) function(_GTK2_GET_VERSION _OUT_major _OUT_minor _OUT_micro _gtkversion_hdr) file(STRINGS ${_gtkversion_hdr} _contents REGEX "#define GTK_M[A-Z]+_VERSION[ \t]+") diff --git a/Modules/FindGTest.cmake b/Modules/FindGTest.cmake index 76ab716..6540171 100644 --- a/Modules/FindGTest.cmake +++ b/Modules/FindGTest.cmake @@ -49,8 +49,8 @@ # The root directory of the Google Test installation (may also be # set as an environment variable) # ``GTEST_MSVC_SEARCH`` -# If compiling with MSVC, this variable can be set to ``MD`` or -# ``MT`` (the default) to enable searching a GTest build tree +# If compiling with MSVC, this variable can be set to ``MT`` or +# ``MD`` (the default) to enable searching a GTest build tree # # # Example usage @@ -160,11 +160,17 @@ if(MSVC) if(GTEST_MSVC_SEARCH STREQUAL "MD") list(APPEND _gtest_libpath_suffixes msvc/gtest-md/Debug - msvc/gtest-md/Release) + msvc/gtest-md/Release + msvc/x64/Debug + msvc/x64/Release + ) elseif(GTEST_MSVC_SEARCH STREQUAL "MT") list(APPEND _gtest_libpath_suffixes msvc/gtest/Debug - msvc/gtest/Release) + msvc/gtest/Release + msvc/x64/Debug + msvc/x64/Release + ) endif() endif() diff --git a/Modules/FindGettext.cmake b/Modules/FindGettext.cmake index 7718468..8035507 100644 --- a/Modules/FindGettext.cmake +++ b/Modules/FindGettext.cmake @@ -77,8 +77,6 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(Gettext REQUIRED_VARS GETTEXT_MSGMERGE_EXECUTABLE GETTEXT_MSGFMT_EXECUTABLE VERSION_VAR GETTEXT_VERSION_STRING) -include(${CMAKE_CURRENT_LIST_DIR}/CMakeParseArguments.cmake) - function(_GETTEXT_GET_UNIQUE_TARGET_NAME _name _unique_name) set(propertyName "_GETTEXT_UNIQUE_COUNTER_${_name}") get_property(currentCounter GLOBAL PROPERTY "${propertyName}") diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake index 30fc5c6..6259ce1 100644 --- a/Modules/FindOpenSSL.cmake +++ b/Modules/FindOpenSSL.cmake @@ -204,7 +204,6 @@ if(WIN32 AND NOT CYGWIN) SSL_EAY_LIBRARY_DEBUG SSL_EAY_LIBRARY_RELEASE) set(OPENSSL_SSL_LIBRARY ${SSL_EAY_LIBRARY} ) set(OPENSSL_CRYPTO_LIBRARY ${LIB_EAY_LIBRARY} ) - set(OPENSSL_LIBRARIES ${SSL_EAY_LIBRARY} ${LIB_EAY_LIBRARY} ) elseif(MINGW) # same player, for MinGW set(LIB_EAY_NAMES crypto libeay32) @@ -232,7 +231,6 @@ if(WIN32 AND NOT CYGWIN) mark_as_advanced(SSL_EAY LIB_EAY) set(OPENSSL_SSL_LIBRARY ${SSL_EAY} ) set(OPENSSL_CRYPTO_LIBRARY ${LIB_EAY} ) - set(OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} ) unset(LIB_EAY_NAMES) unset(SSL_EAY_NAMES) else() @@ -264,7 +262,6 @@ if(WIN32 AND NOT CYGWIN) mark_as_advanced(SSL_EAY LIB_EAY) set(OPENSSL_SSL_LIBRARY ${SSL_EAY} ) set(OPENSSL_CRYPTO_LIBRARY ${LIB_EAY} ) - set(OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} ) endif() else() @@ -298,8 +295,6 @@ else() set(OPENSSL_SSL_LIBRARIES ${OPENSSL_SSL_LIBRARY}) set(OPENSSL_CRYPTO_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY}) - set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY}) - endif() function(from_hex HEX DEC) @@ -371,10 +366,13 @@ endif () include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY} ) + if (OPENSSL_VERSION) find_package_handle_standard_args(OpenSSL REQUIRED_VARS - OPENSSL_LIBRARIES + OPENSSL_SSL_LIBRARY + OPENSSL_CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR VERSION_VAR OPENSSL_VERSION @@ -383,7 +381,8 @@ if (OPENSSL_VERSION) ) else () find_package_handle_standard_args(OpenSSL "Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR" - OPENSSL_LIBRARIES + OPENSSL_SSL_LIBRARY + OPENSSL_CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR ) endif () diff --git a/Modules/FindPackageHandleStandardArgs.cmake b/Modules/FindPackageHandleStandardArgs.cmake index 7b46877..b77925d 100644 --- a/Modules/FindPackageHandleStandardArgs.cmake +++ b/Modules/FindPackageHandleStandardArgs.cmake @@ -130,7 +130,6 @@ message. #]=======================================================================] include(${CMAKE_CURRENT_LIST_DIR}/FindPackageMessage.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/CMakeParseArguments.cmake) # internal helper macro macro(_FPHSA_FAILURE_MESSAGE _msg) diff --git a/Modules/FindPostgreSQL.cmake b/Modules/FindPostgreSQL.cmake index 874128c..9e2194c 100644 --- a/Modules/FindPostgreSQL.cmake +++ b/Modules/FindPostgreSQL.cmake @@ -88,8 +88,13 @@ foreach(suffix ${PostgreSQL_KNOWN_VERSIONS}) "PostgreSQL/${suffix}/include/server") endif() if(UNIX) + list(APPEND PostgreSQL_LIBRARY_ADDITIONAL_SEARCH_SUFFIXES + "pgsql-${suffix}/lib") + list(APPEND PostgreSQL_INCLUDE_ADDITIONAL_SEARCH_SUFFIXES + "pgsql-${suffix}/include") list(APPEND PostgreSQL_TYPE_ADDITIONAL_SEARCH_SUFFIXES - "postgresql/${suffix}/server") + "postgresql/${suffix}/server" + "pgsql-${suffix}/include/server") endif() endforeach() diff --git a/Modules/FindSquish.cmake b/Modules/FindSquish.cmake index 6c8813c..09bdf1f 100644 --- a/Modules/FindSquish.cmake +++ b/Modules/FindSquish.cmake @@ -119,9 +119,6 @@ # # This is deprecated. Use SQUISH_V3_ADD_TEST() if you are using Squish 3.x instead. - -include(CMakeParseArguments) - set(SQUISH_INSTALL_DIR_STRING "Directory containing the bin, doc, and lib directories for Squish; this should be the root of the installation directory.") set(SQUISH_SERVER_EXECUTABLE_STRING "The squishserver executable program.") set(SQUISH_CLIENT_EXECUTABLE_STRING "The squishclient executable program.") diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index c201714..6d1b4ed 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -184,7 +184,6 @@ # :prop_tgt:`CXX_VISIBILITY_PRESET <<LANG>_VISIBILITY_PRESET>` and # :prop_tgt:`VISIBILITY_INLINES_HIDDEN` instead. -include(CMakeParseArguments) include(CheckCXXCompilerFlag) # TODO: Install this macro separately? diff --git a/Modules/InstallRequiredSystemLibraries.cmake b/Modules/InstallRequiredSystemLibraries.cmake index b0446c9..f4ae091 100644 --- a/Modules/InstallRequiredSystemLibraries.cmake +++ b/Modules/InstallRequiredSystemLibraries.cmake @@ -182,7 +182,10 @@ if(MSVC) "${MSVC${v}_CRT_DIR}/msvcp${v}0.dll" ) if(NOT v VERSION_LESS 14) - list(APPEND __install__libs "${MSVC${v}_CRT_DIR}/vcruntime${v}0.dll") + list(APPEND __install__libs + "${MSVC${v}_CRT_DIR}/vcruntime${v}0.dll" + "${MSVC${v}_CRT_DIR}/concrt${v}0.dll" + ) else() list(APPEND __install__libs "${MSVC${v}_CRT_DIR}/msvcr${v}0.dll") endif() @@ -197,7 +200,10 @@ if(MSVC) "${MSVC${v}_CRT_DIR}/msvcp${v}0d.dll" ) if(NOT v VERSION_LESS 14) - list(APPEND __install__libs "${MSVC${v}_CRT_DIR}/vcruntime${v}0d.dll") + list(APPEND __install__libs + "${MSVC${v}_CRT_DIR}/vcruntime${v}0d.dll" + "${MSVC${v}_CRT_DIR}/concrt${v}0d.dll" + ) else() list(APPEND __install__libs "${MSVC${v}_CRT_DIR}/msvcr${v}0d.dll") endif() diff --git a/Modules/Platform/Android-Clang-ASM.cmake b/Modules/Platform/Android-Clang-ASM.cmake new file mode 100644 index 0000000..6448da6 --- /dev/null +++ b/Modules/Platform/Android-Clang-ASM.cmake @@ -0,0 +1,2 @@ +include(Platform/Android-Clang) +__android_compiler_clang(ASM) diff --git a/Modules/Platform/Android-Clang.cmake b/Modules/Platform/Android-Clang.cmake index f0cf4a5..f739ab1 100644 --- a/Modules/Platform/Android-Clang.cmake +++ b/Modules/Platform/Android-Clang.cmake @@ -35,7 +35,9 @@ include(Platform/Android-Common) include(Platform/Android/abi-${CMAKE_ANDROID_ARCH_ABI}-Clang) macro(__android_compiler_clang lang) - __android_compiler_common(${lang}) + if(NOT "x${lang}" STREQUAL "xASM") + __android_compiler_common(${lang}) + endif() if(NOT CMAKE_${lang}_COMPILER_TARGET) set(CMAKE_${lang}_COMPILER_TARGET "${_ANDROID_ABI_CLANG_TARGET}") endif() diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake index 6b34c8f..93255ae 100644 --- a/Modules/UseJava.cmake +++ b/Modules/UseJava.cmake @@ -403,8 +403,6 @@ # Sets the directory where the header files will be generated. Same behavior as option # '-d' of javah tool. If not specified, ${CMAKE_CURRENT_BINARY_DIR} is used as output directory. -include(${CMAKE_CURRENT_LIST_DIR}/CMakeParseArguments.cmake) - function (__java_copy_file src dest comment) add_custom_command( OUTPUT ${dest} diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake index 651f9f1..277f4ca 100644 --- a/Modules/UseSWIG.cmake +++ b/Modules/UseSWIG.cmake @@ -212,6 +212,7 @@ macro(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) "${swig_source_file_fullname}" MAIN_DEPENDENCY "${swig_source_file_fullname}" DEPENDS ${SWIG_MODULE_${name}_EXTRA_DEPS} + IMPLICIT_DEPENDS CXX "${swig_source_file_fullname}" COMMENT "Swig source") set_source_files_properties("${swig_generated_file_fullname}" ${swig_extra_generated_files} PROPERTIES GENERATED 1) @@ -231,8 +232,6 @@ endmacro() macro(SWIG_ADD_LIBRARY name) - - include(CMakeParseArguments) set(options "") set(oneValueArgs LANGUAGE TYPE) @@ -340,4 +339,3 @@ macro(SWIG_LINK_LIBRARIES name) message(SEND_ERROR "Cannot find Swig library \"${name}\".") endif() endmacro() - diff --git a/Modules/WriteBasicConfigVersionFile.cmake b/Modules/WriteBasicConfigVersionFile.cmake index 20c769e..7c9467a 100644 --- a/Modules/WriteBasicConfigVersionFile.cmake +++ b/Modules/WriteBasicConfigVersionFile.cmake @@ -18,8 +18,6 @@ # # Deprecated, see WRITE_BASIC_PACKAGE_VERSION_FILE(), it is identical. -include(CMakeParseArguments) - function(WRITE_BASIC_CONFIG_VERSION_FILE _filename) set(options ) diff --git a/Modules/WriteCompilerDetectionHeader.cmake b/Modules/WriteCompilerDetectionHeader.cmake index a390f4b..ba249e1 100644 --- a/Modules/WriteCompilerDetectionHeader.cmake +++ b/Modules/WriteCompilerDetectionHeader.cmake @@ -216,7 +216,6 @@ # CompatSupport_DEPRECATED= # ) -include(${CMAKE_CURRENT_LIST_DIR}/CMakeParseArguments.cmake) include(${CMAKE_CURRENT_LIST_DIR}/CMakeCompilerIdDetection.cmake) function(_load_compiler_variables CompilerId lang) diff --git a/Source/CMakeInstallDestinations.cmake b/Source/CMakeInstallDestinations.cmake index 023f6c0..28f4e87 100644 --- a/Source/CMakeInstallDestinations.cmake +++ b/Source/CMakeInstallDestinations.cmake @@ -25,6 +25,12 @@ set(CMAKE_DOC_DIR_DESC "docs") set(CMAKE_MAN_DIR_DESC "man pages") set(CMAKE_XDGDATA_DIR_DESC "XDG specific files") +set(CMake_INSTALL_INFIX "" CACHE STRING "") +set_property(CACHE CMake_INSTALL_INFIX PROPERTY HELPSTRING + "Intermediate installation path (empty by default)" + ) +mark_as_advanced(CMake_INSTALL_INFIX) + foreach(v CMAKE_BIN_DIR CMAKE_DATA_DIR @@ -41,7 +47,7 @@ foreach(v # Use the default when the user did not set this variable. if(NOT ${v}) - set(${v} "${${v}_DEFAULT}") + set(${v} "${CMake_INSTALL_INFIX}${${v}_DEFAULT}") endif() # Remove leading slash to treat as relative to install prefix. string(REGEX REPLACE "^/" "" ${v} "${${v}}") diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index ae9c31e..fde01c1 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 7) -set(CMake_VERSION_PATCH 20161216) +set(CMake_VERSION_PATCH 20170112) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 36566a4..5c50da8 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -173,7 +173,11 @@ int cmCPackDebGenerator::PackageComponentsAllInOne( std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) + this->GetOutputExtension()); // all GROUP in one vs all COMPONENT in one - localToplevel += "/" + compInstDirName; + // if must be here otherwise non component paths have a trailing / while + // components don't + if (!compInstDirName.empty()) { + localToplevel += "/" + compInstDirName; + } /* replace the TEMP DIRECTORY with the component one */ this->SetOption("CPACK_TEMPORARY_DIRECTORY", localToplevel.c_str()); diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index 2c31f60..4d23e45 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -305,6 +305,9 @@ void cmCTestMemCheckHandler::GenerateDartOutput(cmXMLWriter& xml) case cmCTestMemCheckHandler::ADDRESS_SANITIZER: xml.Attribute("Checker", "AddressSanitizer"); break; + case cmCTestMemCheckHandler::LEAK_SANITIZER: + xml.Attribute("Checker", "LeakSanitizer"); + break; case cmCTestMemCheckHandler::THREAD_SANITIZER: xml.Attribute("Checker", "ThreadSanitizer"); break; @@ -459,6 +462,12 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() this->LogWithPID = true; // even if we give the log file the pid is added } if (this->CTest->GetCTestConfiguration("MemoryCheckType") == + "LeakSanitizer") { + this->MemoryTester = this->CTest->GetCTestConfiguration("CMakeCommand"); + this->MemoryTesterStyle = cmCTestMemCheckHandler::LEAK_SANITIZER; + this->LogWithPID = true; // even if we give the log file the pid is added + } + if (this->CTest->GetCTestConfiguration("MemoryCheckType") == "ThreadSanitizer") { this->MemoryTester = this->CTest->GetCTestConfiguration("CMakeCommand"); this->MemoryTesterStyle = cmCTestMemCheckHandler::THREAD_SANITIZER; @@ -586,6 +595,7 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() } // these are almost the same but the env var used is different case cmCTestMemCheckHandler::ADDRESS_SANITIZER: + case cmCTestMemCheckHandler::LEAK_SANITIZER: case cmCTestMemCheckHandler::THREAD_SANITIZER: case cmCTestMemCheckHandler::MEMORY_SANITIZER: case cmCTestMemCheckHandler::UB_SANITIZER: { @@ -597,12 +607,20 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() this->MemoryTesterDynamicOptions.push_back("-E"); this->MemoryTesterDynamicOptions.push_back("env"); std::string envVar; - std::string extraOptions = + std::string extraOptions = ":" + this->CTest->GetCTestConfiguration("MemoryCheckSanitizerOptions"); + std::string suppressionsOption; + if (!this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile") + .empty()) { + suppressionsOption = ":suppressions=" + + this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile"); + } if (this->MemoryTesterStyle == cmCTestMemCheckHandler::ADDRESS_SANITIZER) { envVar = "ASAN_OPTIONS"; - extraOptions += " detect_leaks=1"; + } else if (this->MemoryTesterStyle == + cmCTestMemCheckHandler::LEAK_SANITIZER) { + envVar = "LSAN_OPTIONS"; } else if (this->MemoryTesterStyle == cmCTestMemCheckHandler::THREAD_SANITIZER) { envVar = "TSAN_OPTIONS"; @@ -614,8 +632,9 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() envVar = "UBSAN_OPTIONS"; } std::string outputFile = - envVar + "=log_path=\"" + this->MemoryTesterOutputFile + "\" "; - this->MemoryTesterEnvironmentVariable = outputFile + extraOptions; + envVar + "=log_path=\"" + this->MemoryTesterOutputFile + "\""; + this->MemoryTesterEnvironmentVariable = + outputFile + extraOptions + suppressionsOption; break; } default: @@ -644,6 +663,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckOutput(const std::string& str, case cmCTestMemCheckHandler::PURIFY: return this->ProcessMemCheckPurifyOutput(str, log, results); case cmCTestMemCheckHandler::ADDRESS_SANITIZER: + case cmCTestMemCheckHandler::LEAK_SANITIZER: case cmCTestMemCheckHandler::THREAD_SANITIZER: case cmCTestMemCheckHandler::MEMORY_SANITIZER: case cmCTestMemCheckHandler::UB_SANITIZER: @@ -680,6 +700,9 @@ bool cmCTestMemCheckHandler::ProcessMemCheckSanitizerOutput( case cmCTestMemCheckHandler::ADDRESS_SANITIZER: regex = "ERROR: AddressSanitizer: (.*) on.*"; break; + case cmCTestMemCheckHandler::LEAK_SANITIZER: + // use leakWarning regex + break; case cmCTestMemCheckHandler::THREAD_SANITIZER: regex = "WARNING: ThreadSanitizer: (.*) \\(pid=.*\\)"; break; diff --git a/Source/CTest/cmCTestMemCheckHandler.h b/Source/CTest/cmCTestMemCheckHandler.h index 5faace0..ff8b593 100644 --- a/Source/CTest/cmCTestMemCheckHandler.h +++ b/Source/CTest/cmCTestMemCheckHandler.h @@ -47,6 +47,7 @@ private: BOUNDS_CHECKER, // checkers after here do not use the standard error list ADDRESS_SANITIZER, + LEAK_SANITIZER, THREAD_SANITIZER, MEMORY_SANITIZER, UB_SANITIZER diff --git a/Source/QtDialog/RegexExplorer.cxx b/Source/QtDialog/RegexExplorer.cxx index 1512166..abed70e 100644 --- a/Source/QtDialog/RegexExplorer.cxx +++ b/Source/QtDialog/RegexExplorer.cxx @@ -64,10 +64,32 @@ void RegexExplorer::on_inputText_textChanged() return; } + std::string matchingText; + + if (matchAll->isChecked()) { + const char* p = m_text.c_str(); + while (m_regexParser.find(p)) { + std::string::size_type l = m_regexParser.start(); + std::string::size_type r = m_regexParser.end(); + if (r - l == 0) { + // matched empty string + clearMatch(); + return; + } + if (!matchingText.empty()) { + matchingText += ";"; + } + matchingText += std::string(p + l, r - l); + p += r; + } + } else { + matchingText = m_regexParser.match(0); + } + #ifdef QT_NO_STL - QString matchText = m_regexParser.match(0).c_str(); + QString matchText = matchingText.c_str(); #else - QString matchText = QString::fromStdString(m_regexParser.match(0)); + QString matchText = QString::fromStdString(matchingText); #endif match0->setPlainText(matchText); @@ -95,8 +117,16 @@ void RegexExplorer::on_matchNumber_currentIndexChanged(int index) matchN->setPlainText(match); } +void RegexExplorer::on_matchAll_toggled(bool checked) +{ + Q_UNUSED(checked); + + on_inputText_textChanged(); +} + void RegexExplorer::clearMatch() { + m_matched = false; match0->clear(); matchN->clear(); } diff --git a/Source/QtDialog/RegexExplorer.h b/Source/QtDialog/RegexExplorer.h index f1c1e5f..caef975 100644 --- a/Source/QtDialog/RegexExplorer.h +++ b/Source/QtDialog/RegexExplorer.h @@ -22,6 +22,7 @@ private slots: void on_regularExpression_textChanged(const QString& text); void on_inputText_textChanged(); void on_matchNumber_currentIndexChanged(int index); + void on_matchAll_toggled(bool checked); private: static void setStatusColor(QWidget* widget, bool successful); diff --git a/Source/QtDialog/RegexExplorer.ui b/Source/QtDialog/RegexExplorer.ui index 2c2d761..0af6999 100644 --- a/Source/QtDialog/RegexExplorer.ui +++ b/Source/QtDialog/RegexExplorer.ui @@ -104,11 +104,38 @@ <widget class="QLineEdit" name="regularExpression"/> </item> <item> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Complete Match</string> - </property> - </widget> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Complete Match</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_5"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QCheckBox" name="matchAll"> + <property name="text"> + <string>Match All</string> + </property> + </widget> + </item> + </layout> </item> <item> <widget class="QPlainTextEdit" name="match0"> diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx index e6000db..9d4b9cc 100644 --- a/Source/cmDependsC.cxx +++ b/Source/cmDependsC.cxx @@ -12,7 +12,7 @@ #include "cmSystemTools.h" #define INCLUDE_REGEX_LINE \ - "^[ \t]*#[ \t]*(include|import)[ \t]*[<\"]([^\">]+)([\">])" + "^[ \t]*[#%][ \t]*(include|import)[ \t]*[<\"]([^\">]+)([\">])" #define INCLUDE_REGEX_LINE_MARKER "#IncludeRegexLine: " #define INCLUDE_REGEX_SCAN_MARKER "#IncludeRegexScan: " @@ -420,7 +420,7 @@ void cmDependsC::SetupTransforms() if (!this->TransformRules.empty()) { // Construct the regular expression to match lines to be // transformed. - std::string xform = "^([ \t]*#[ \t]*(include|import)[ \t]*)("; + std::string xform = "^([ \t]*[#%][ \t]*(include|import)[ \t]*)("; const char* sep = ""; for (TransformRulesType::const_iterator tri = this->TransformRules.begin(); tri != this->TransformRules.end(); ++tri) { diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index f544e8a..2dffcaa 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -48,6 +48,7 @@ cmExtraCodeBlocksGenerator::GetFactory() #if defined(_WIN32) factory.AddSupportedGlobalGenerator("MinGW Makefiles"); factory.AddSupportedGlobalGenerator("NMake Makefiles"); + factory.AddSupportedGlobalGenerator("NMake Makefiles JOM"); // disable until somebody actually tests it: // this->AddSupportedGlobalGenerator("MSYS Makefiles"); #endif @@ -741,7 +742,7 @@ std::string cmExtraCodeBlocksGenerator::BuildMakeCommand( } std::string generator = this->GlobalGenerator->GetName(); - if (generator == "NMake Makefiles") { + if (generator == "NMake Makefiles" || generator == "NMake Makefiles JOM") { // For Windows ConvertToOutputPath already adds quotes when required. // These need to be escaped, see // https://gitlab.kitware.com/cmake/cmake/issues/13952 diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index dfefefe..36ba520 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -323,16 +323,12 @@ std::string cmExtraSublimeTextGenerator::BuildMakeCommand( std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile); command += ", \"/NOLOGO\", \"/f\", \""; command += makefileName + "\""; - command += ", \"VERBOSE=1\", \""; - command += target; - command += "\""; + command += ", \"" + target + "\""; } else if (generator == "Ninja") { std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile); command += ", \"-f\", \""; command += makefileName + "\""; - command += ", \"-v\", \""; - command += target; - command += "\""; + command += ", \"" + target + "\""; } else { std::string makefileName; if (generator == "MinGW Makefiles") { @@ -344,9 +340,7 @@ std::string cmExtraSublimeTextGenerator::BuildMakeCommand( } command += ", \"-f\", \""; command += makefileName + "\""; - command += ", \"VERBOSE=1\", \""; - command += target; - command += "\""; + command += ", \"" + target + "\""; } return command; } diff --git a/Source/cmFileMonitor.cxx b/Source/cmFileMonitor.cxx index 03bbf42..909be78 100644 --- a/Source/cmFileMonitor.cxx +++ b/Source/cmFileMonitor.cxx @@ -334,6 +334,9 @@ void cmFileMonitor::MonitorPaths(const std::vector<std::string>& paths, rootSegment)); // Can not be both filename and root part of the path! const std::string& currentSegment = pathSegments[i]; + if (currentSegment.empty()) { + continue; + } cmIBaseWatcher* nextWatcher = currentWatcher->Find(currentSegment); if (!nextWatcher) { diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 736aa91..96535eb 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1977,6 +1977,22 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, buildSettings->AddAttribute("HEADER_SEARCH_PATHS", dirs.CreateList()); } + if (this->XcodeVersion >= 60) { + // Add those per-language flags in addition to HEADER_SEARCH_PATHS to gain + // system include directory awareness. We need to also keep on setting + // HEADER_SEARCH_PATHS to work around a missing compile options flag for + // GNU assembly files (#16449) + for (std::set<std::string>::iterator li = languages.begin(); + li != languages.end(); ++li) { + std::string includeFlags = this->CurrentLocalGenerator->GetIncludeFlags( + includes, gtgt, *li, true, false, configName); + + if (!includeFlags.empty()) { + cflags[*li] += " " + includeFlags; + } + } + } + bool same_gflags = true; std::map<std::string, std::string> gflags; std::string const* last_gflag = 0; diff --git a/Source/cmListFileLexer.c b/Source/cmListFileLexer.c index 31faca1..56559f6 100644 --- a/Source/cmListFileLexer.c +++ b/Source/cmListFileLexer.c @@ -2518,7 +2518,7 @@ static void cmListFileLexerDestroy(cmListFileLexer* lexer) } /*--------------------------------------------------------------------------*/ -cmListFileLexer* cmListFileLexer_New() +cmListFileLexer* cmListFileLexer_New(void) { cmListFileLexer* lexer = (cmListFileLexer*)malloc(sizeof(cmListFileLexer)); if (!lexer) { diff --git a/Source/cmListFileLexer.h b/Source/cmListFileLexer.h index dfbad5e..c9fb6da 100644 --- a/Source/cmListFileLexer.h +++ b/Source/cmListFileLexer.h @@ -46,7 +46,7 @@ typedef struct cmListFileLexer_s cmListFileLexer; extern "C" { #endif -cmListFileLexer* cmListFileLexer_New(); +cmListFileLexer* cmListFileLexer_New(void); int cmListFileLexer_SetFileName(cmListFileLexer*, const char*, cmListFileLexer_BOM* bom); int cmListFileLexer_SetString(cmListFileLexer*, const char*); diff --git a/Source/cmListFileLexer.in.l b/Source/cmListFileLexer.in.l index 4b389b9..dd64923 100644 --- a/Source/cmListFileLexer.in.l +++ b/Source/cmListFileLexer.in.l @@ -398,7 +398,7 @@ static void cmListFileLexerDestroy(cmListFileLexer* lexer) } /*--------------------------------------------------------------------------*/ -cmListFileLexer* cmListFileLexer_New() +cmListFileLexer* cmListFileLexer_New(void) { cmListFileLexer* lexer = (cmListFileLexer*)malloc(sizeof(cmListFileLexer)); if (!lexer) { diff --git a/Source/cmLocale.h b/Source/cmLocale.h index e8e751d..cca7cf5 100644 --- a/Source/cmLocale.h +++ b/Source/cmLocale.h @@ -6,10 +6,11 @@ #include <cmConfigure.h> #include <locale.h> +#include <string> class cmLocaleRAII { - const char* OldLocale; + std::string OldLocale; public: cmLocaleRAII() @@ -17,7 +18,7 @@ public: { setlocale(LC_CTYPE, ""); } - ~cmLocaleRAII() { setlocale(LC_CTYPE, this->OldLocale); } + ~cmLocaleRAII() { setlocale(LC_CTYPE, this->OldLocale.c_str()); } }; #endif diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index fccb486..cfc0495 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2215,7 +2215,7 @@ const char* cmMakefile::GetRequiredDefinition(const std::string& name) const const char* ret = this->GetDefinition(name); if (!ret) { cmSystemTools::Error("Error required internal CMake variable not " - "set, cmake may be not be built correctly.\n", + "set, cmake may not be built correctly.\n", "Missing variable is:\n", name.c_str()); return ""; } diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx index f0847b1..6d4c302 100644 --- a/Source/cmQtAutoGeneratorInitializer.cxx +++ b/Source/cmQtAutoGeneratorInitializer.cxx @@ -99,39 +99,64 @@ static std::string GetQtMajorVersion(cmGeneratorTarget const* target) } static void SetupSourceFiles(cmGeneratorTarget const* target, - std::vector<std::string>& skipMoc, - std::vector<std::string>& mocSources, - std::vector<std::string>& mocHeaders, - std::vector<std::string>& skipUic) + std::vector<std::string>& mocUicSources, + std::vector<std::string>& mocUicHeaders, + std::vector<std::string>& skipMocList, + std::vector<std::string>& skipUicList) { cmMakefile* makefile = target->Target->GetMakefile(); std::vector<cmSourceFile*> srcFiles; target->GetConfigCommonSourceFiles(srcFiles); + const bool targetMoc = target->GetPropertyAsBool("AUTOMOC"); + const bool targetUic = target->GetPropertyAsBool("AUTOUIC"); + cmFilePathChecksum fpathCheckSum(makefile); for (std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin(); fileIt != srcFiles.end(); ++fileIt) { cmSourceFile* sf = *fileIt; + const cmSystemTools::FileFormat fileType = + cmSystemTools::GetFileFormat(sf->GetExtension().c_str()); + + if (!(fileType == cmSystemTools::CXX_FILE_FORMAT) && + !(fileType == cmSystemTools::HEADER_FILE_FORMAT)) { + continue; + } + if (cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED"))) { + continue; + } const std::string absFile = cmsys::SystemTools::GetRealPath(sf->GetFullPath()); - const std::string ext = sf->GetExtension(); - - if (cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOUIC"))) { - skipUic.push_back(absFile); - } - - if (!cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED"))) { - if (cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOMOC"))) { - skipMoc.push_back(absFile); - } else { - cmSystemTools::FileFormat fileType = - cmSystemTools::GetFileFormat(ext.c_str()); - if (fileType == cmSystemTools::CXX_FILE_FORMAT) { - mocSources.push_back(absFile); - } else if (fileType == cmSystemTools::HEADER_FILE_FORMAT) { - mocHeaders.push_back(absFile); - } + // Skip flags + const bool skipAll = + cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOGEN")); + const bool skipMoc = + skipAll || cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOMOC")); + const bool skipUic = + skipAll || cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOUIC")); + // Add file name to skip lists. + // Do this even when the file is not added to the sources/headers lists + // because the file name may be extracted from an other file when + // processing + if (skipMoc) { + skipMocList.push_back(absFile); + } + if (skipUic) { + skipUicList.push_back(absFile); + } + + if ((targetMoc && !skipMoc) || (targetUic && !skipUic)) { + // Add file name to sources or headers list + switch (fileType) { + case cmSystemTools::CXX_FILE_FORMAT: + mocUicSources.push_back(absFile); + break; + case cmSystemTools::HEADER_FILE_FORMAT: + mocUicHeaders.push_back(absFile); + break; + default: + break; } } } @@ -158,7 +183,6 @@ static void GetCompileDefinitionsAndDirectories( static void MocSetupAutoTarget( cmGeneratorTarget const* target, const std::string& autogenTargetName, std::vector<std::string> const& skipMoc, - std::vector<std::string> const& mocHeaders, std::map<std::string, std::string>& configIncludes, std::map<std::string, std::string>& configDefines) { @@ -172,9 +196,6 @@ static void MocSetupAutoTarget( makefile->AddDefinition( "_skip_moc", cmOutputConverter::EscapeForCMake(cmJoin(skipMoc, ";")).c_str()); - makefile->AddDefinition( - "_moc_headers", - cmOutputConverter::EscapeForCMake(cmJoin(mocHeaders, ";")).c_str()); bool relaxedMode = makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE"); makefile->AddDefinition("_moc_relaxed_mode", relaxedMode ? "TRUE" : "FALSE"); @@ -569,7 +590,9 @@ static void RccSetupAutoTarget(cmGeneratorTarget const* target, std::string ext = sf->GetExtension(); if (ext == "qrc") { std::string absFile = cmsys::SystemTools::GetRealPath(sf->GetFullPath()); - bool skip = cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC")); + const bool skip = + cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOGEN")) || + cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC")); if (!skip) { _rcc_files += sepRccFiles; @@ -632,7 +655,8 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenSources( cmMakefile* makefile = target->Target->GetMakefile(); const std::string mocCppFile = GetAutogenTargetBuildDir(target) + "moc_compilation.cpp"; - makefile->GetOrCreateSource(mocCppFile, true); + cmSourceFile* gf = makefile->GetOrCreateSource(mocCppFile, true); + gf->SetProperty("SKIP_AUTOGEN", "On"); target->AddSource(mocCppFile); } } @@ -747,6 +771,7 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget( fileIt != srcFiles.end(); ++fileIt) { cmSourceFile* sf = *fileIt; if (sf->GetExtension() == "qrc" && + !cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOGEN")) && !cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC"))) { { const std::string absFile = @@ -763,7 +788,8 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget( rccOutputFile += ".cpp"; // Add rcc output file to origin target sources - makefile->GetOrCreateSource(rccOutputFile, true); + cmSourceFile* gf = makefile->GetOrCreateSource(rccOutputFile, true); + gf->SetProperty("SKIP_AUTOGEN", "On"); target->AddSource(rccOutputFile); // Register rcc output file as generated autogenOutputFiles.push_back(rccOutputFile); @@ -850,10 +876,10 @@ void cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget( cmOutputConverter::EscapeForCMake(target->GetName()).c_str()); makefile->AddDefinition("_target_qt_version", qtMajorVersion.c_str()); - std::vector<std::string> skipUic; + std::vector<std::string> mocUicSources; + std::vector<std::string> mocUicHeaders; std::vector<std::string> skipMoc; - std::vector<std::string> mocSources; - std::vector<std::string> mocHeaders; + std::vector<std::string> skipUic; std::map<std::string, std::string> configMocIncludes; std::map<std::string, std::string> configMocDefines; std::map<std::string, std::string> configUicOptions; @@ -861,14 +887,18 @@ void cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget( if (target->GetPropertyAsBool("AUTOMOC") || target->GetPropertyAsBool("AUTOUIC") || target->GetPropertyAsBool("AUTORCC")) { - SetupSourceFiles(target, skipMoc, mocSources, mocHeaders, skipUic); + SetupSourceFiles(target, mocUicSources, mocUicHeaders, skipMoc, skipUic); } makefile->AddDefinition( - "_cpp_files", - cmOutputConverter::EscapeForCMake(cmJoin(mocSources, ";")).c_str()); + "_moc_uic_sources", + cmOutputConverter::EscapeForCMake(cmJoin(mocUicSources, ";")).c_str()); + makefile->AddDefinition( + "_moc_uic_headers", + cmOutputConverter::EscapeForCMake(cmJoin(mocUicHeaders, ";")).c_str()); + if (target->GetPropertyAsBool("AUTOMOC")) { - MocSetupAutoTarget(target, autogenTargetName, skipMoc, mocHeaders, - configMocIncludes, configMocDefines); + MocSetupAutoTarget(target, autogenTargetName, skipMoc, configMocIncludes, + configMocDefines); } if (target->GetPropertyAsBool("AUTOUIC")) { UicSetupAutoTarget(target, skipUic, configUicOptions); diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index a9a9c49..f5c33fe 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -6,7 +6,6 @@ #include <assert.h> #include <cmConfigure.h> #include <cmsys/FStream.hxx> -#include <cmsys/RegularExpression.hxx> #include <cmsys/Terminal.h> #include <iostream> #include <sstream> @@ -28,27 +27,6 @@ #include <unistd.h> #endif -static bool requiresMocing(const std::string& text, std::string& macroName) -{ - // this simple check is much much faster than the regexp - if (strstr(text.c_str(), "Q_OBJECT") == CM_NULLPTR && - strstr(text.c_str(), "Q_GADGET") == CM_NULLPTR) { - return false; - } - - cmsys::RegularExpression qObjectRegExp("[\n][ \t]*Q_OBJECT[^a-zA-Z0-9_]"); - if (qObjectRegExp.find(text)) { - macroName = "Q_OBJECT"; - return true; - } - cmsys::RegularExpression qGadgetRegExp("[\n][ \t]*Q_GADGET[^a-zA-Z0-9_]"); - if (qGadgetRegExp.find(text)) { - macroName = "Q_GADGET"; - return true; - } - return false; -} - static std::string findMatchingHeader( const std::string& absPath, const std::string& mocSubDir, const std::string& basename, @@ -62,6 +40,7 @@ static std::string findMatchingHeader( header = sourceFilePath; break; } + // Try subdirectory instead if (!mocSubDir.empty()) { sourceFilePath = mocSubDir + basename + "." + (*ext); if (cmsys::SystemTools::FileExists(sourceFilePath.c_str())) { @@ -101,6 +80,21 @@ static bool FileNameIsUnique(const std::string& filePath, return true; } +static std::string ReadAll(const std::string& filename) +{ + cmsys::ifstream file(filename.c_str()); + std::ostringstream stream; + stream << file.rdbuf(); + file.close(); + return stream.str(); +} + +static bool ListContains(const std::vector<std::string>& list, + const std::string& entry) +{ + return (std::find(list.begin(), list.end(), entry) != list.end()); +} + cmQtAutoGenerators::cmQtAutoGenerators() : Verbose(cmsys::SystemTools::HasEnv("VERBOSE")) , ColorOutput(true) @@ -119,6 +113,15 @@ cmQtAutoGenerators::cmQtAutoGenerators() this->ColorOutput = false; } } + + // Precompile regular expressions + this->RegExpQObject.compile("[\n][ \t]*Q_OBJECT[^a-zA-Z0-9_]"); + this->RegExpQGadget.compile("[\n][ \t]*Q_GADGET[^a-zA-Z0-9_]"); + this->RegExpMocInclude.compile( + "[\n][ \t]*#[ \t]*include[ \t]+" + "[\"<](([^ \">]+/)?moc_[^ \">/]+\\.cpp|[^ \">]+\\.moc)[\">]"); + this->RegExpUicInclude.compile("[\n][ \t]*#[ \t]*include[ \t]+" + "[\"<](([^ \">]+/)?ui_[^ \">/]+\\.h)[\">]"); } void cmQtAutoGenerators::MergeUicOptions( @@ -195,7 +198,7 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile( if (!makefile->ReadListFile(filename.c_str())) { std::ostringstream err; - err << "AUTOGEN: error processing file: " << filename << std::endl; + err << "AutoGen: error processing file: " << filename << std::endl; this->LogError(err.str()); return false; } @@ -224,11 +227,14 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile( this->RccExecutable = makefile->GetSafeDefinition("AM_QT_RCC_EXECUTABLE"); // - File Lists - this->Sources = makefile->GetSafeDefinition("AM_SOURCES"); - this->Headers = makefile->GetSafeDefinition("AM_HEADERS"); + cmSystemTools::ExpandListArgument(makefile->GetSafeDefinition("AM_SOURCES"), + this->Sources); + cmSystemTools::ExpandListArgument(makefile->GetSafeDefinition("AM_HEADERS"), + this->Headers); // - Moc - this->SkipMoc = makefile->GetSafeDefinition("AM_SKIP_MOC"); + cmSystemTools::ExpandListArgument(makefile->GetSafeDefinition("AM_SKIP_MOC"), + this->SkipMoc); { std::string compileDefsPropOrig = "AM_MOC_COMPILE_DEFINITIONS"; std::string compileDefsProp = compileDefsPropOrig; @@ -255,7 +261,8 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile( this->MocOptionsStr = makefile->GetSafeDefinition("AM_MOC_OPTIONS"); // - Uic - this->SkipUic = makefile->GetSafeDefinition("AM_SKIP_UIC"); + cmSystemTools::ExpandListArgument(makefile->GetSafeDefinition("AM_SKIP_UIC"), + this->SkipUic); { const char* uicOptionsFiles = makefile->GetSafeDefinition("AM_UIC_OPTIONS_FILES"); @@ -321,7 +328,7 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile( } if (this->RccSources.size() != rccInputLists.size()) { std::ostringstream err; - err << "AUTOGEN: RCC sources lists size missmatch in: " << filename; + err << "AutoGen: RCC sources lists size missmatch in: " << filename; err << std::endl; this->LogError(err.str()); return false; @@ -484,15 +491,6 @@ void cmQtAutoGenerators::Init() } } -static std::string ReadAll(const std::string& filename) -{ - cmsys::ifstream file(filename.c_str()); - std::ostringstream stream; - stream << file.rdbuf(); - file.close(); - return stream.str(); -} - bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile) { // If settings changed everything needs to be re-generated. @@ -510,72 +508,46 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile) // key = moc source filepath, value = moc output filepath std::map<std::string, std::string> includedMocs; - // collect all headers which may need to be mocced - std::set<std::string> headerFiles; - - std::vector<std::string> sourceFiles; - cmSystemTools::ExpandListArgument(this->Sources, sourceFiles); - - const std::vector<std::string>& headerExtensions = - makefile->GetCMakeInstance()->GetHeaderExtensions(); - + std::map<std::string, std::string> notIncludedMocs; std::map<std::string, std::vector<std::string> > includedUis; - std::map<std::string, std::vector<std::string> > skippedUis; - std::vector<std::string> uicSkipped; - cmSystemTools::ExpandListArgument(this->SkipUic, uicSkipped); - - for (std::vector<std::string>::const_iterator it = sourceFiles.begin(); - it != sourceFiles.end(); ++it) { - const bool skipUic = - std::find(uicSkipped.begin(), uicSkipped.end(), *it) != uicSkipped.end(); - std::map<std::string, std::vector<std::string> >& uiFiles = - skipUic ? skippedUis : includedUis; - const std::string& absFilename = *it; - if (this->Verbose) { - std::ostringstream err; - err << "AUTOGEN: Checking " << absFilename << std::endl; - this->LogInfo(err.str()); - } - if (this->MocRelaxedMode) { - if (!this->ParseCppFile(absFilename, headerExtensions, includedMocs, - uiFiles)) { - return false; - } - } else { - if (!this->StrictParseCppFile(absFilename, headerExtensions, - includedMocs, uiFiles)) { + // collects all headers which may need to be mocced + std::set<std::string> headerFilesMoc; + std::set<std::string> headerFilesUic; + + // Parse sources + { + const std::vector<std::string>& headerExtensions = + makefile->GetCMakeInstance()->GetHeaderExtensions(); + + for (std::vector<std::string>::const_iterator it = this->Sources.begin(); + it != this->Sources.end(); ++it) { + const std::string& absFilename = *it; + // Parse source file for MOC/UIC + if (!this->ParseSourceFile(absFilename, headerExtensions, includedMocs, + includedUis, this->MocRelaxedMode)) { return false; } + // Find additional headers + this->SearchHeadersForSourceFile(absFilename, headerExtensions, + headerFilesMoc, headerFilesUic); } - this->SearchHeadersForCppFile(absFilename, headerExtensions, headerFiles); } - { - std::vector<std::string> mocSkipped; - cmSystemTools::ExpandListArgument(this->SkipMoc, mocSkipped); - for (std::vector<std::string>::const_iterator it = mocSkipped.begin(); - it != mocSkipped.end(); ++it) { - if (std::find(uicSkipped.begin(), uicSkipped.end(), *it) != - uicSkipped.end()) { - const std::string& absFilename = *it; - if (this->Verbose) { - std::ostringstream err; - err << "AUTOGEN: Checking " << absFilename << std::endl; - this->LogInfo(err.str()); - } - this->ParseForUic(absFilename, includedUis); - } + // Parse headers + for (std::vector<std::string>::const_iterator it = this->Headers.begin(); + it != this->Headers.end(); ++it) { + const std::string& headerName = *it; + if (!this->MocSkipTest(headerName)) { + headerFilesMoc.insert(this->Headers.begin(), this->Headers.end()); + } + if (!this->UicSkipTest(headerName)) { + headerFilesUic.insert(this->Headers.begin(), this->Headers.end()); } } + this->ParseHeaders(headerFilesMoc, headerFilesUic, includedMocs, + notIncludedMocs, includedUis); - std::vector<std::string> headerFilesVec; - cmSystemTools::ExpandListArgument(this->Headers, headerFilesVec); - headerFiles.insert(headerFilesVec.begin(), headerFilesVec.end()); - - // key = moc source filepath, value = moc output filename - std::map<std::string, std::string> notIncludedMocs; - this->ParseHeaders(headerFiles, includedMocs, notIncludedMocs, includedUis); - + // Generate files if (!this->MocExecutable.empty()) { if (!this->GenerateMocFiles(includedMocs, notIncludedMocs)) { return false; @@ -598,181 +570,262 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile) /** * @return True on success */ -bool cmQtAutoGenerators::ParseCppFile( +bool cmQtAutoGenerators::ParseSourceFile( const std::string& absFilename, const std::vector<std::string>& headerExtensions, std::map<std::string, std::string>& includedMocs, - std::map<std::string, std::vector<std::string> >& includedUis) + std::map<std::string, std::vector<std::string> >& includedUis, bool relaxed) { - cmsys::RegularExpression mocIncludeRegExp( - "[\n][ \t]*#[ \t]*include[ \t]+" - "[\"<](([^ \">]+/)?moc_[^ \">/]+\\.cpp|[^ \">]+\\.moc)[\">]"); - + bool success = true; const std::string contentsString = ReadAll(absFilename); if (contentsString.empty()) { std::ostringstream err; - err << "AUTOGEN: warning: " << absFilename << ": file is empty\n" - << std::endl; + err << "AutoGen: Warning: " << absFilename << "\n" + << "The file is empty\n"; this->LogWarning(err.str()); - return true; + } else { + // Parse source contents for MOC + if (success && !this->MocSkipTest(absFilename)) { + success = this->ParseContentForMoc( + absFilename, contentsString, headerExtensions, includedMocs, relaxed); + } + // Parse source contents for UIC + if (success && !this->UicSkipTest(absFilename)) { + this->ParseContentForUic(absFilename, contentsString, includedUis); + } } - this->ParseForUic(absFilename, contentsString, includedUis); - if (this->MocExecutable.empty()) { - return true; + return success; +} + +bool cmQtAutoGenerators::requiresMocing(const std::string& text, + std::string& macroName) +{ + // Run a simple check before an expensive regular expression check + if (strstr(text.c_str(), "Q_OBJECT") != CM_NULLPTR) { + if (this->RegExpQObject.find(text)) { + macroName = "Q_OBJECT"; + return true; + } + } + if (strstr(text.c_str(), "Q_GADGET") != CM_NULLPTR) { + if (this->RegExpQGadget.find(text)) { + macroName = "Q_GADGET"; + return true; + } } + return false; +} - const std::string absPath = cmsys::SystemTools::GetFilenamePath( - cmsys::SystemTools::GetRealPath(absFilename)) + +void cmQtAutoGenerators::ParseContentForUic( + const std::string& absFilename, const std::string& contentsString, + std::map<std::string, std::vector<std::string> >& includedUis) +{ + // Process + if (this->Verbose) { + std::ostringstream err; + err << "AutoUic: Checking " << absFilename << "\n"; + this->LogInfo(err.str()); + } + + const std::string realName = cmsys::SystemTools::GetRealPath(absFilename); + const char* contentChars = contentsString.c_str(); + if (strstr(contentChars, "ui_") != CM_NULLPTR) { + while (this->RegExpUicInclude.find(contentChars)) { + const std::string currentUi = this->RegExpUicInclude.match(1); + const std::string basename = + cmsys::SystemTools::GetFilenameWithoutLastExtension(currentUi); + // basename should be the part of the ui filename used for + // finding the correct header, so we need to remove the ui_ part + includedUis[realName].push_back(basename.substr(3)); + contentChars += this->RegExpUicInclude.end(); + } + } +} + +/** + * @return True on success + */ +bool cmQtAutoGenerators::ParseContentForMoc( + const std::string& absFilename, const std::string& contentsString, + const std::vector<std::string>& headerExtensions, + std::map<std::string, std::string>& includedMocs, bool relaxed) +{ + // Process + if (this->Verbose) { + std::ostringstream err; + err << "AutoMoc: Checking " << absFilename << "\n"; + this->LogInfo(err.str()); + } + + const std::string scannedFileAbsPath = + cmsys::SystemTools::GetFilenamePath( + cmsys::SystemTools::GetRealPath(absFilename)) + '/'; const std::string scannedFileBasename = cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename); + std::string macroName; - const bool requiresMoc = requiresMocing(contentsString, macroName); - bool dotMocIncluded = false; - bool mocUnderscoreIncluded = false; + const bool requiresMoc = this->requiresMocing(contentsString, macroName); + bool ownDotMocIncluded = false; + bool ownMocUnderscoreIncluded = false; std::string ownMocUnderscoreFile; - std::string ownDotMocFile; std::string ownMocHeaderFile; - std::string::size_type matchOffset = 0; // first a simple string check for "moc" is *much* faster than the regexp, // and if the string search already fails, we don't have to try the // expensive regexp - if ((strstr(contentsString.c_str(), "moc") != CM_NULLPTR) && - (mocIncludeRegExp.find(contentsString))) { - // for every moc include in the file - do { - const std::string currentMoc = mocIncludeRegExp.match(1); - + const char* contentChars = contentsString.c_str(); + if (strstr(contentChars, "moc") != CM_NULLPTR) { + // Iterate over all included moc files + while (this->RegExpMocInclude.find(contentChars)) { + const std::string currentMoc = this->RegExpMocInclude.match(1); + // Basename of the current moc include std::string basename = cmsys::SystemTools::GetFilenameWithoutLastExtension(currentMoc); - const bool moc_style = cmHasLiteralPrefix(basename, "moc_"); // If the moc include is of the moc_foo.cpp style we expect // the Q_OBJECT class declaration in a header file. // If the moc include is of the foo.moc style we need to look for // a Q_OBJECT macro in the current source file, if it contains the // macro we generate the moc file from the source file. - // Q_OBJECT - if (moc_style) { + if (cmHasLiteralPrefix(basename, "moc_")) { + // Include: moc_FOO.cxx // basename should be the part of the moc filename used for // finding the correct header, so we need to remove the moc_ part basename = basename.substr(4); - std::string mocSubDir = extractSubDir(absPath, currentMoc); - std::string headerToMoc = - findMatchingHeader(absPath, mocSubDir, basename, headerExtensions); + const std::string mocSubDir = + extractSubDir(scannedFileAbsPath, currentMoc); + const std::string headerToMoc = findMatchingHeader( + scannedFileAbsPath, mocSubDir, basename, headerExtensions); if (!headerToMoc.empty()) { includedMocs[headerToMoc] = currentMoc; - if (basename == scannedFileBasename) { - mocUnderscoreIncluded = true; + if (relaxed && (basename == scannedFileBasename)) { + ownMocUnderscoreIncluded = true; ownMocUnderscoreFile = currentMoc; ownMocHeaderFile = headerToMoc; } } else { std::ostringstream err; - err << "AUTOGEN: error: " << absFilename << ": The file " - << "includes the moc file \"" << currentMoc << "\", " - << "but could not find header \"" << basename << '{' + err << "AutoMoc: Error: " << absFilename << "\n" + << "The file includes the moc file \"" << currentMoc + << "\", but could not find header \"" << basename << '{' << this->JoinExts(headerExtensions) << "}\" "; if (mocSubDir.empty()) { - err << "in " << absPath << "\n" << std::endl; + err << "in " << scannedFileAbsPath << "\n"; } else { - err << "neither in " << absPath << " nor in " << mocSubDir << "\n" - << std::endl; + err << "neither in " << scannedFileAbsPath << " nor in " + << mocSubDir << "\n"; } this->LogError(err.str()); return false; } } else { - std::string fileToMoc = absFilename; - if (!requiresMoc || basename != scannedFileBasename) { - std::string mocSubDir = extractSubDir(absPath, currentMoc); - std::string headerToMoc = - findMatchingHeader(absPath, mocSubDir, basename, headerExtensions); - if (!headerToMoc.empty()) { - // this is for KDE4 compatibility: - fileToMoc = headerToMoc; - if (!requiresMoc && basename == scannedFileBasename) { - std::ostringstream err; - err << "AUTOGEN: warning: " << absFilename - << ": The file " - "includes the moc file \"" - << currentMoc << "\", but does not contain a " << macroName - << " macro. Running moc on " - << "\"" << headerToMoc << "\" ! Include \"moc_" << basename - << ".cpp\" for a compatibility with " - "strict mode (see CMAKE_AUTOMOC_RELAXED_MODE).\n" - << std::endl; - this->LogWarning(err.str()); + // Include: FOO.moc + std::string fileToMoc; + if (relaxed) { + // Mode: Relaxed + if (!requiresMoc || basename != scannedFileBasename) { + const std::string mocSubDir = + extractSubDir(scannedFileAbsPath, currentMoc); + const std::string headerToMoc = findMatchingHeader( + scannedFileAbsPath, mocSubDir, basename, headerExtensions); + if (!headerToMoc.empty()) { + // This is for KDE4 compatibility: + fileToMoc = headerToMoc; + if (!requiresMoc && basename == scannedFileBasename) { + std::ostringstream err; + err << "AutoMoc: Warning: " << absFilename << "\n" + << "The file includes the moc file \"" << currentMoc + << "\", but does not contain a " << macroName + << " macro. Running moc on " + << "\"" << headerToMoc << "\" ! Include \"moc_" << basename + << ".cpp\" for a compatibility with " + "strict mode (see CMAKE_AUTOMOC_RELAXED_MODE).\n"; + this->LogWarning(err.str()); + } else { + std::ostringstream err; + err << "AutoMoc: Warning: " << absFilename << "\n" + << "The file includes the moc file \"" << currentMoc + << "\" instead of \"moc_" << basename + << ".cpp\". Running moc on " + << "\"" << headerToMoc << "\" ! Include \"moc_" << basename + << ".cpp\" for compatibility with " + "strict mode (see CMAKE_AUTOMOC_RELAXED_MODE).\n"; + this->LogWarning(err.str()); + } } else { std::ostringstream err; - err << "AUTOGEN: warning: " << absFilename - << ": The file " - "includes the moc file \"" - << currentMoc << "\" instead of \"moc_" << basename - << ".cpp\". " - "Running moc on " - << "\"" << headerToMoc << "\" ! Include \"moc_" << basename - << ".cpp\" for compatibility with " - "strict mode (see CMAKE_AUTOMOC_RELAXED_MODE).\n" - << std::endl; - this->LogWarning(err.str()); + err << "AutoMoc: Error: " << absFilename << "\n" + << "The file includes the moc file \"" << currentMoc + << "\", which seems to be the moc file from a different " + "source file. CMake also could not find a matching " + "header.\n"; + this->LogError(err.str()); + return false; } } else { + // Include self + fileToMoc = absFilename; + ownDotMocIncluded = true; + } + } else { + // Mode: Strict + if (basename != scannedFileBasename) { + // Don't allow FOO.moc include other than self in strict mode std::ostringstream err; - err << "AUTOGEN: error: " << absFilename - << ": The file " - "includes the moc file \"" - << currentMoc + err << "AutoMoc: Error: " << absFilename << "\n" + << "The file includes the moc file \"" << currentMoc << "\", which seems to be the moc file from a different " - "source file. CMake also could not find a matching " - "header.\n" - << std::endl; + "source file. This is not supported. Include \"" + << scannedFileBasename + << ".moc\" to run moc on this source file.\n"; this->LogError(err.str()); return false; + } else { + // Include self + fileToMoc = absFilename; + ownDotMocIncluded = true; } - } else { - dotMocIncluded = true; - ownDotMocFile = currentMoc; } - includedMocs[fileToMoc] = currentMoc; + if (!fileToMoc.empty()) { + includedMocs[fileToMoc] = currentMoc; + } } - matchOffset += mocIncludeRegExp.end(); - } while (mocIncludeRegExp.find(contentsString.c_str() + matchOffset)); + // Forward content pointer + contentChars += this->RegExpMocInclude.end(); + } } // In this case, check whether the scanned file itself contains a Q_OBJECT. // If this is the case, the moc_foo.cpp should probably be generated from // foo.cpp instead of foo.h, because otherwise it won't build. // But warn, since this is not how it is supposed to be used. - if (!dotMocIncluded && requiresMoc) { - if (mocUnderscoreIncluded) { - // this is for KDE4 compatibility: + if (requiresMoc && !ownDotMocIncluded) { + if (relaxed && ownMocUnderscoreIncluded) { + // This is for KDE4 compatibility: std::ostringstream err; - err << "AUTOGEN: warning: " << absFilename << ": The file " - << "contains a " << macroName << " macro, but does not " - "include " - << "\"" << scannedFileBasename << ".moc\", but instead " - "includes " + err << "AutoMoc: Warning: " << absFilename << "\n" + << "The file contains a " << macroName + << " macro, but does not include " + << "\"" << scannedFileBasename << ".moc\", but instead includes " << "\"" << ownMocUnderscoreFile << "\". Running moc on " << "\"" << absFilename << "\" ! Better include \"" << scannedFileBasename << ".moc\" for compatibility with " - "strict mode (see CMAKE_AUTOMOC_RELAXED_MODE).\n" - << std::endl; + "strict mode (see CMAKE_AUTOMOC_RELAXED_MODE).\n"; this->LogWarning(err.str()); + // Use scanned source file instead of scanned header file as moc source includedMocs[absFilename] = ownMocUnderscoreFile; includedMocs.erase(ownMocHeaderFile); } else { - // otherwise always error out since it will not compile: + // Otherwise always error out since it will not compile: std::ostringstream err; - err << "AUTOGEN: error: " << absFilename << ": The file " - << "contains a " << macroName << " macro, but does not " - "include " - << "\"" << scannedFileBasename << ".moc\" !\n" - << std::endl; + err << "AutoMoc: Error: " << absFilename << "\n" + << "The file contains a " << macroName + << " macro, but does not include " + << "\"" << scannedFileBasename << ".moc\" !\n"; this->LogError(err.str()); return false; } @@ -781,237 +834,90 @@ bool cmQtAutoGenerators::ParseCppFile( return true; } -/** - * @return True on success - */ -bool cmQtAutoGenerators::StrictParseCppFile( - const std::string& absFilename, - const std::vector<std::string>& headerExtensions, - std::map<std::string, std::string>& includedMocs, - std::map<std::string, std::vector<std::string> >& includedUis) -{ - cmsys::RegularExpression mocIncludeRegExp( - "[\n][ \t]*#[ \t]*include[ \t]+" - "[\"<](([^ \">]+/)?moc_[^ \">/]+\\.cpp|[^ \">]+\\.moc)[\">]"); - - const std::string contentsString = ReadAll(absFilename); - if (contentsString.empty()) { - std::ostringstream err; - err << "AUTOGEN: warning: " << absFilename << ": file is empty\n" - << std::endl; - this->LogWarning(err.str()); - return true; - } - this->ParseForUic(absFilename, contentsString, includedUis); - if (this->MocExecutable.empty()) { - return true; - } - - const std::string absPath = cmsys::SystemTools::GetFilenamePath( - cmsys::SystemTools::GetRealPath(absFilename)) + - '/'; - const std::string scannedFileBasename = - cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename); - - bool dotMocIncluded = false; - - std::string::size_type matchOffset = 0; - // first a simple string check for "moc" is *much* faster than the regexp, - // and if the string search already fails, we don't have to try the - // expensive regexp - if ((strstr(contentsString.c_str(), "moc") != CM_NULLPTR) && - (mocIncludeRegExp.find(contentsString))) { - // for every moc include in the file - do { - const std::string currentMoc = mocIncludeRegExp.match(1); - - std::string basename = - cmsys::SystemTools::GetFilenameWithoutLastExtension(currentMoc); - const bool mocUnderscoreStyle = cmHasLiteralPrefix(basename, "moc_"); - - // If the moc include is of the moc_foo.cpp style we expect - // the Q_OBJECT class declaration in a header file. - // If the moc include is of the foo.moc style we need to look for - // a Q_OBJECT macro in the current source file, if it contains the - // macro we generate the moc file from the source file. - if (mocUnderscoreStyle) { - // basename should be the part of the moc filename used for - // finding the correct header, so we need to remove the moc_ part - basename = basename.substr(4); - std::string mocSubDir = extractSubDir(absPath, currentMoc); - std::string headerToMoc = - findMatchingHeader(absPath, mocSubDir, basename, headerExtensions); - - if (!headerToMoc.empty()) { - includedMocs[headerToMoc] = currentMoc; - } else { - std::ostringstream err; - err << "AUTOGEN: error: " << absFilename << " The file " - << "includes the moc file \"" << currentMoc << "\", " - << "but could not find header \"" << basename << '{' - << this->JoinExts(headerExtensions) << "}\" "; - if (mocSubDir.empty()) { - err << "in " << absPath << "\n" << std::endl; - } else { - err << "neither in " << absPath << " nor in " << mocSubDir << "\n" - << std::endl; - } - this->LogError(err.str()); - return false; - } - } else { - if (basename != scannedFileBasename) { - std::ostringstream err; - err << "AUTOGEN: error: " << absFilename - << ": The file " - "includes the moc file \"" - << currentMoc - << "\", which seems to be the moc file from a different " - "source file. This is not supported. " - "Include \"" - << scannedFileBasename << ".moc\" to run " - "moc on this source file.\n" - << std::endl; - this->LogError(err.str()); - return false; - } - dotMocIncluded = true; - includedMocs[absFilename] = currentMoc; - } - matchOffset += mocIncludeRegExp.end(); - } while (mocIncludeRegExp.find(contentsString.c_str() + matchOffset)); - } - - // In this case, check whether the scanned file itself contains a Q_OBJECT. - // If this is the case, the moc_foo.cpp should probably be generated from - // foo.cpp instead of foo.h, because otherwise it won't build. - // But warn, since this is not how it is supposed to be used. - std::string macroName; - if (!dotMocIncluded && requiresMocing(contentsString, macroName)) { - // otherwise always error out since it will not compile: - std::ostringstream err; - err << "AUTOGEN: error: " << absFilename << ": The file " - << "contains a " << macroName << " macro, but does not include " - << "\"" << scannedFileBasename << ".moc\" !\n" - << std::endl; - this->LogError(err.str()); - return false; - } - - return true; -} - -void cmQtAutoGenerators::ParseForUic( - const std::string& absFilename, - std::map<std::string, std::vector<std::string> >& includedUis) -{ - if (this->UicExecutable.empty()) { - return; - } - const std::string contentsString = ReadAll(absFilename); - if (contentsString.empty()) { - std::ostringstream err; - err << "AUTOGEN: warning: " << absFilename << ": file is empty\n" - << std::endl; - this->LogWarning(err.str()); - return; - } - this->ParseForUic(absFilename, contentsString, includedUis); -} - -void cmQtAutoGenerators::ParseForUic( - const std::string& absFilename, const std::string& contentsString, - std::map<std::string, std::vector<std::string> >& includedUis) -{ - if (this->UicExecutable.empty()) { - return; - } - cmsys::RegularExpression uiIncludeRegExp( - "[\n][ \t]*#[ \t]*include[ \t]+" - "[\"<](([^ \">]+/)?ui_[^ \">/]+\\.h)[\">]"); - - std::string::size_type matchOffset = 0; - - const std::string realName = cmsys::SystemTools::GetRealPath(absFilename); - - matchOffset = 0; - if ((strstr(contentsString.c_str(), "ui_") != CM_NULLPTR) && - (uiIncludeRegExp.find(contentsString))) { - do { - const std::string currentUi = uiIncludeRegExp.match(1); - - std::string basename = - cmsys::SystemTools::GetFilenameWithoutLastExtension(currentUi); - - // basename should be the part of the ui filename used for - // finding the correct header, so we need to remove the ui_ part - basename = basename.substr(3); - - includedUis[realName].push_back(basename); - - matchOffset += uiIncludeRegExp.end(); - } while (uiIncludeRegExp.find(contentsString.c_str() + matchOffset)); - } -} - -void cmQtAutoGenerators::SearchHeadersForCppFile( +void cmQtAutoGenerators::SearchHeadersForSourceFile( const std::string& absFilename, const std::vector<std::string>& headerExtensions, - std::set<std::string>& absHeaders) + std::set<std::string>& absHeadersMoc, std::set<std::string>& absHeadersUic) { // search for header files and private header files we may need to moc: - const std::string basename = - cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename); - const std::string absPath = cmsys::SystemTools::GetFilenamePath( - cmsys::SystemTools::GetRealPath(absFilename)) + - '/'; + std::string basepath = cmsys::SystemTools::GetFilenamePath( + cmsys::SystemTools::GetRealPath(absFilename)); + basepath += '/'; + basepath += cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename); + // Search for regular header for (std::vector<std::string>::const_iterator ext = headerExtensions.begin(); ext != headerExtensions.end(); ++ext) { - const std::string headerName = absPath + basename + "." + (*ext); + const std::string headerName = basepath + "." + (*ext); if (cmsys::SystemTools::FileExists(headerName.c_str())) { - absHeaders.insert(headerName); + // Moc headers + if (!this->MocSkipTest(absFilename) && !this->MocSkipTest(headerName)) { + absHeadersMoc.insert(headerName); + } + // Uic headers + if (!this->UicSkipTest(absFilename) && !this->UicSkipTest(headerName)) { + absHeadersUic.insert(headerName); + } break; } } + // Search for private header for (std::vector<std::string>::const_iterator ext = headerExtensions.begin(); ext != headerExtensions.end(); ++ext) { - const std::string privateHeaderName = absPath + basename + "_p." + (*ext); - if (cmsys::SystemTools::FileExists(privateHeaderName.c_str())) { - absHeaders.insert(privateHeaderName); + const std::string headerName = basepath + "_p." + (*ext); + if (cmsys::SystemTools::FileExists(headerName.c_str())) { + // Moc headers + if (!this->MocSkipTest(absFilename) && !this->MocSkipTest(headerName)) { + absHeadersMoc.insert(headerName); + } + // Uic headers + if (!this->UicSkipTest(absFilename) && !this->UicSkipTest(headerName)) { + absHeadersUic.insert(headerName); + } break; } } } void cmQtAutoGenerators::ParseHeaders( - const std::set<std::string>& absHeaders, + const std::set<std::string>& absHeadersMoc, + const std::set<std::string>& absHeadersUic, const std::map<std::string, std::string>& includedMocs, std::map<std::string, std::string>& notIncludedMocs, std::map<std::string, std::vector<std::string> >& includedUis) { - for (std::set<std::string>::const_iterator hIt = absHeaders.begin(); - hIt != absHeaders.end(); ++hIt) { + // Merged header files list to read files only once + std::set<std::string> headerFiles; + headerFiles.insert(absHeadersMoc.begin(), absHeadersMoc.end()); + headerFiles.insert(absHeadersUic.begin(), absHeadersUic.end()); + + for (std::set<std::string>::const_iterator hIt = headerFiles.begin(); + hIt != headerFiles.end(); ++hIt) { const std::string& headerName = *hIt; const std::string contents = ReadAll(headerName); - if (!this->MocExecutable.empty() && - includedMocs.find(headerName) == includedMocs.end()) { + // Parse header content for MOC + if ((absHeadersMoc.find(headerName) != absHeadersMoc.end()) && + (includedMocs.find(headerName) == includedMocs.end())) { + // Process if (this->Verbose) { std::ostringstream err; - err << "AUTOGEN: Checking " << headerName << std::endl; + err << "AutoMoc: Checking " << headerName << "\n"; this->LogInfo(err.str()); } - std::string macroName; - if (requiresMocing(contents, macroName)) { + if (this->requiresMocing(contents, macroName)) { notIncludedMocs[headerName] = fpathCheckSum.getPart(headerName) + "/moc_" + cmsys::SystemTools::GetFilenameWithoutLastExtension(headerName) + ".cpp"; } } - this->ParseForUic(headerName, contents, includedUis); + + // Parse header content for UIC + if (absHeadersUic.find(headerName) != absHeadersUic.end()) { + this->ParseContentForUic(headerName, contents, includedUis); + } } } @@ -1027,7 +933,7 @@ bool cmQtAutoGenerators::GenerateMocFiles( mergedMocs.insert(notIncludedMocs.begin(), notIncludedMocs.end()); if (this->NameCollisionTest(mergedMocs, collisions)) { std::ostringstream err; - err << "AUTOGEN: error: " + err << "AutoMoc: Error: " "The same moc file will be generated " "from different sources." << std::endl @@ -1098,7 +1004,7 @@ bool cmQtAutoGenerators::GenerateMocFiles( // nothing changed: don't touch the moc_compilation.cpp file if (this->Verbose) { std::ostringstream err; - err << "AUTOGEN: " << this->OutMocCppFilenameRel << " still up to date" + err << "AutoMoc: " << this->OutMocCppFilenameRel << " still up to date" << std::endl; this->LogInfo(err.str()); } @@ -1113,14 +1019,14 @@ bool cmQtAutoGenerators::GenerateMocFiles( this->LogBold(msg); } // Make sure the parent directory exists - bool success = this->makeParentDirectory(this->OutMocCppFilenameAbs); + bool success = this->MakeParentDirectory(this->OutMocCppFilenameAbs); if (success) { cmsys::ofstream outfile; outfile.open(this->OutMocCppFilenameAbs.c_str(), std::ios::trunc); if (!outfile) { success = false; std::ostringstream err; - err << "AUTOGEN: error opening " << this->OutMocCppFilenameAbs << "\n"; + err << "AutoMoc: error opening " << this->OutMocCppFilenameAbs << "\n"; this->LogError(err.str()); } else { outfile << automocSource; @@ -1128,7 +1034,7 @@ bool cmQtAutoGenerators::GenerateMocFiles( if (!outfile.good()) { success = false; std::ostringstream err; - err << "AUTOGEN: error writing " << this->OutMocCppFilenameAbs << "\n"; + err << "AutoMoc: error writing " << this->OutMocCppFilenameAbs << "\n"; this->LogError(err.str()); } } @@ -1154,7 +1060,7 @@ bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile, this->LogBold("Generating MOC source " + mocFileRel); // Make sure the parent directory exists - if (!this->makeParentDirectory(mocFileAbs)) { + if (!this->MakeParentDirectory(mocFileAbs)) { this->RunMocFailed = true; return false; } @@ -1185,7 +1091,7 @@ bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile, if (!result || retVal) { { std::ostringstream err; - err << "AUTOGEN: error: moc process for " << mocFileRel << " failed:\n" + err << "AutoMoc: Error: moc process for " << mocFileRel << " failed:\n" << output << std::endl; this->LogError(err.str()); } @@ -1228,7 +1134,7 @@ bool cmQtAutoGenerators::GenerateUiFiles( std::multimap<std::string, std::string> collisions; if (this->NameCollisionTest(testMap, collisions)) { std::ostringstream err; - err << "AUTOGEN: error: The same ui_NAME.h file will be generated " + err << "AutoUic: Error: The same ui_NAME.h file will be generated " "from different sources." << std::endl << "To avoid this error rename the source files." << std::endl; @@ -1276,7 +1182,7 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& realName, this->LogBold("Generating UIC header " + uicFileRel); // Make sure the parent directory exists - if (!this->makeParentDirectory(uicFileAbs)) { + if (!this->MakeParentDirectory(uicFileAbs)) { this->RunUicFailed = true; return false; } @@ -1309,7 +1215,7 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& realName, if (!result || retVal) { { std::ostringstream err; - err << "AUTOUIC: error: uic process for " << uicFileRel + err << "AutoUic: Error: uic process for " << uicFileRel << " needed by\n \"" << realName << "\"\nfailed:\n" << output << std::endl; this->LogError(err.str()); @@ -1358,7 +1264,7 @@ bool cmQtAutoGenerators::GenerateQrcFiles() std::multimap<std::string, std::string> collisions; if (this->NameCollisionTest(qrcGenMap, collisions)) { std::ostringstream err; - err << "AUTOGEN: error: The same qrc_NAME.cpp file" + err << "AutoRcc: Error: The same qrc_NAME.cpp file" " will be generated from different sources." << std::endl << "To avoid this error rename the source .qrc files." << std::endl; @@ -1415,7 +1321,7 @@ bool cmQtAutoGenerators::GenerateQrc(const std::string& qrcInputFile, } // Make sure the parent directory exists - if (!this->makeParentDirectory(qrcOutputFile)) { + if (!this->MakeParentDirectory(qrcOutputFile)) { this->RunRccFailed = true; return false; } @@ -1445,7 +1351,7 @@ bool cmQtAutoGenerators::GenerateQrc(const std::string& qrcInputFile, if (!result || retVal) { { std::ostringstream err; - err << "AUTORCC: error: rcc process for " << qrcOutputFile + err << "AutoRcc: Error: rcc process for " << qrcOutputFile << " failed:\n" << output << std::endl; this->LogError(err.str()); @@ -1460,6 +1366,37 @@ bool cmQtAutoGenerators::GenerateQrc(const std::string& qrcInputFile, } /** + * @brief Tests if the file should be ignored for moc scanning + * @return True if the file should be ignored + */ +bool cmQtAutoGenerators::MocSkipTest(const std::string& absFilename) +{ + // Test if moc scanning is enabled + if (!this->MocExecutable.empty()) { + // Test if the file name is on the skip list + if (!ListContains(this->SkipMoc, absFilename)) { + return false; + } + } + return true; +} + +/** + * @brief Tests if the file name is in the skip list + */ +bool cmQtAutoGenerators::UicSkipTest(const std::string& absFilename) +{ + // Test if uic scanning is enabled + if (!this->UicExecutable.empty()) { + // Test if the file name is on the skip list + if (!ListContains(this->SkipUic, absFilename)) { + return false; + } + } + return true; +} + +/** * @brief Collects name collisions as output/input pairs * @return True if there were collisions */ @@ -1551,7 +1488,7 @@ void cmQtAutoGenerators::LogCommand(const std::vector<std::string>& command) * @brief Generates the parent directory of the given file on demand * @return True on success */ -bool cmQtAutoGenerators::makeParentDirectory(const std::string& filename) +bool cmQtAutoGenerators::MakeParentDirectory(const std::string& filename) { bool success = true; const std::string dirName = cmSystemTools::GetFilenamePath(filename); @@ -1559,7 +1496,7 @@ bool cmQtAutoGenerators::makeParentDirectory(const std::string& filename) success = cmsys::SystemTools::MakeDirectory(dirName); if (!success) { std::ostringstream err; - err << "AUTOGEN: Directory creation failed: " << dirName << std::endl; + err << "AutoGen: Directory creation failed: " << dirName << std::endl; this->LogError(err.str()); } } diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h index c241579..d0c7066 100644 --- a/Source/cmQtAutoGenerators.h +++ b/Source/cmQtAutoGenerators.h @@ -5,6 +5,7 @@ #include <cmConfigure.h> // IWYU pragma: keep #include <cmFilePathChecksum.h> +#include <cmsys/RegularExpression.hxx> #include <list> #include <map> @@ -48,37 +49,46 @@ private: bool GenerateQrc(const std::string& qrcInputFile, const std::string& qrcOutputFile, bool unique_n); - bool ParseCppFile( + bool ParseSourceFile( const std::string& absFilename, const std::vector<std::string>& headerExtensions, std::map<std::string, std::string>& includedMocs, - std::map<std::string, std::vector<std::string> >& includedUis); - bool StrictParseCppFile( - const std::string& absFilename, - const std::vector<std::string>& headerExtensions, - std::map<std::string, std::string>& includedMocs, - std::map<std::string, std::vector<std::string> >& includedUis); - void SearchHeadersForCppFile( + std::map<std::string, std::vector<std::string> >& includedUis, + bool relaxed); + void SearchHeadersForSourceFile( const std::string& absFilename, const std::vector<std::string>& headerExtensions, - std::set<std::string>& absHeaders); + std::set<std::string>& absHeadersMoc, + std::set<std::string>& absHeadersUic); void ParseHeaders( - const std::set<std::string>& absHeaders, + const std::set<std::string>& absHeadersMoc, + const std::set<std::string>& absHeadersUic, const std::map<std::string, std::string>& includedMocs, std::map<std::string, std::string>& notIncludedMocs, std::map<std::string, std::vector<std::string> >& includedUis); - void ParseForUic( + bool requiresMocing(const std::string& text, std::string& macroName); + + void ParseContentForUic( const std::string& fileName, const std::string& contentsString, std::map<std::string, std::vector<std::string> >& includedUis); + bool ParseContentForMoc(const std::string& absFilename, + const std::string& contentsString, + const std::vector<std::string>& headerExtensions, + std::map<std::string, std::string>& includedMocs, + bool relaxed); + void ParseForUic( const std::string& fileName, std::map<std::string, std::vector<std::string> >& includedUis); void Init(); + bool MocSkipTest(const std::string& absFilename); + bool UicSkipTest(const std::string& absFilename); + bool NameCollisionTest(const std::map<std::string, std::string>& genFiles, std::multimap<std::string, std::string>& collisions); @@ -91,7 +101,7 @@ private: void LogError(const std::string& message); void LogCommand(const std::vector<std::string>& command); - bool makeParentDirectory(const std::string& filename); + bool MakeParentDirectory(const std::string& filename); std::string JoinExts(const std::vector<std::string>& lst); @@ -117,10 +127,10 @@ private: std::string UicExecutable; std::string RccExecutable; // - File lists - std::string Sources; - std::string Headers; + std::vector<std::string> Sources; + std::vector<std::string> Headers; // - Moc - std::string SkipMoc; + std::vector<std::string> SkipMoc; std::string MocCompileDefinitionsStr; std::string MocIncludesStr; std::string MocOptionsStr; @@ -130,7 +140,7 @@ private: std::list<std::string> MocDefinitions; std::vector<std::string> MocOptions; // - Uic - std::string SkipUic; + std::vector<std::string> SkipUic; std::vector<std::string> UicTargetOptions; std::map<std::string, std::string> UicOptions; // - Rcc @@ -142,6 +152,10 @@ private: std::string OldCompileSettingsStr; // - Utility cmFilePathChecksum fpathCheckSum; + cmsys::RegularExpression RegExpQObject; + cmsys::RegularExpression RegExpQGadget; + cmsys::RegularExpression RegExpMocInclude; + cmsys::RegularExpression RegExpUicInclude; // - Flags bool IncludeProjectDirsBefore; bool Verbose; diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx index f47cb33..334a05a 100644 --- a/Source/cmServerProtocol.cxx +++ b/Source/cmServerProtocol.cxx @@ -731,12 +731,16 @@ static Json::Value DumpTarget(cmGeneratorTarget* target, Json::Value result = Json::objectValue; result[kNAME_KEY] = target->GetName(); - result[kTYPE_KEY] = typeName; - result[kFULL_NAME_KEY] = target->GetFullName(config); result[kSOURCE_DIRECTORY_KEY] = lg->GetCurrentSourceDirectory(); result[kBUILD_DIRECTORY_KEY] = lg->GetCurrentBinaryDirectory(); + if (type == cmStateEnums::INTERFACE_LIBRARY) { + return result; + } + + result[kFULL_NAME_KEY] = target->GetFullName(config); + if (target->HaveWellDefinedOutputFiles()) { Json::Value artifacts = Json::arrayValue; artifacts.append(target->GetFullPath(config, false)); @@ -997,6 +1001,8 @@ cmServerResponse cmServerProtocol1_0::ProcessConfigure( } } + cmSystemTools::ResetErrorOccuredFlag(); // Reset error state + if (cm->AddCMakePaths() != 1) { return request.ReportError("Failed to set CMake paths."); } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index ee4ff39..9261ca8 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -858,6 +858,12 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } + if (prop == "TYPE") { + std::ostringstream e; + e << "TYPE property is read-only\n"; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); + return; + } if (prop == "EXPORT_NAME" && this->IsImported()) { std::ostringstream e; e << "EXPORT_NAME property can't be set on imported targets (\"" diff --git a/Tests/IncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/CMakeLists.txt index 4920582..db18462 100644 --- a/Tests/IncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/CMakeLists.txt @@ -3,7 +3,9 @@ project(IncludeDirectories) if (((CMAKE_C_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.4) OR CMAKE_C_COMPILER_ID STREQUAL Clang OR CMAKE_C_COMPILER_ID STREQUAL AppleClang) - AND (CMAKE_GENERATOR STREQUAL "Unix Makefiles" OR CMAKE_GENERATOR STREQUAL "Ninja")) + AND (CMAKE_GENERATOR STREQUAL "Unix Makefiles" + OR CMAKE_GENERATOR STREQUAL "Ninja" + OR (CMAKE_GENERATOR STREQUAL "Xcode" AND NOT XCODE_VERSION VERSION_LESS 6.0))) include(CheckCXXCompilerFlag) check_cxx_compiler_flag(-Wunused-variable run_sys_includes_test) if(run_sys_includes_test) diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt index dcee85e..5078f30 100644 --- a/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt @@ -15,10 +15,17 @@ target_include_directories(upstream SYSTEM PUBLIC ) add_library(config_specific INTERFACE) -set(testConfig ${CMAKE_BUILD_TYPE}) -target_include_directories(config_specific SYSTEM INTERFACE - "$<$<CONFIG:${testConfig}>:${CMAKE_CURRENT_SOURCE_DIR}/config_specific>" -) +if(CMAKE_GENERATOR STREQUAL "Xcode") + # CMAKE_BUILD_TYPE does not work here for multi-config generators + target_include_directories(config_specific SYSTEM INTERFACE + "${CMAKE_CURRENT_SOURCE_DIR}/config_specific" + ) +else() + set(testConfig ${CMAKE_BUILD_TYPE}) + target_include_directories(config_specific SYSTEM INTERFACE + "$<$<CONFIG:${testConfig}>:${CMAKE_CURRENT_SOURCE_DIR}/config_specific>" + ) +endif() add_library(consumer consumer.cpp) target_link_libraries(consumer upstream config_specific) diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt index 6d4e2c4..4b90ad8 100644 --- a/Tests/QtAutogen/CMakeLists.txt +++ b/Tests/QtAutogen/CMakeLists.txt @@ -139,6 +139,69 @@ if (automoc_rerun_result) message(SEND_ERROR "Second build of automoc_rerun failed.") endif() +# -- Test: AUTOMOC, SKIP_AUTOMOC +# Test for SKIP_AUTOMOC and SKIP_AUTOGEN on an AUTOMOC enabled target +qtx_wrap_cpp(skipMocWrapMoc + skipSource/qItemA.hpp + skipSource/qItemB.hpp) +set(skipMocSources + skipMoc.cpp + skipSource/qItemA.cpp + skipSource/qItemB.cpp + skipSource/qItemC.cpp) +set_property(SOURCE skipSource/qItemA.cpp PROPERTY SKIP_AUTOMOC ON) +set_property(SOURCE skipSource/qItemB.cpp PROPERTY SKIP_AUTOGEN ON) +# AUTOMOC enabled only +add_executable(skipMocA ${skipMocSources} ${skipMocWrapMoc}) +set_property(TARGET skipMocA PROPERTY AUTOMOC ON) +target_link_libraries(skipMocA ${QT_LIBRARIES}) +# AUTOMOC and AUTOUIC enabled +add_executable(skipMocB ${skipMocSources} ${skipMocWrapMoc}) +set_property(TARGET skipMocB PROPERTY AUTOMOC ON) +set_property(TARGET skipMocB PROPERTY AUTOUIC ON) +target_link_libraries(skipMocB ${QT_LIBRARIES}) + +# -- Test: AUTOUIC, SKIP_AUTOUIC +# Test for SKIP_AUTOUIC and SKIP_AUTOGEN on an AUTOUIC enabled target +set(skipUicSources + skipUic.cpp + skipSource/skipUicGen.cpp + skipSource/skipUicNoGen1.cpp + skipSource/skipUicNoGen2.cpp +) +set_property(SOURCE skipSource/skipUicNoGen1.cpp PROPERTY SKIP_AUTOUIC ON) +set_property(SOURCE skipSource/skipUicNoGen2.cpp PROPERTY SKIP_AUTOGEN ON) +# AUTOUIC enabled +add_executable(skipUicA ${skipUicSources}) +set_property(TARGET skipUicA PROPERTY AUTOUIC ON) +target_link_libraries(skipUicA ${QT_LIBRARIES}) +# AUTOUIC and AUTOMOC enabled +add_executable(skipUicB ${skipUicSources}) +set_property(TARGET skipUicB PROPERTY AUTOUIC ON) +set_property(TARGET skipUicB PROPERTY AUTOMOC ON) +target_link_libraries(skipUicB ${QT_LIBRARIES}) + +# -- Test: AUTORCC, SKIP_AUTORCC +# Test for SKIP_AUTORCC and SKIP_AUTOGEN on an AUTORCC enabled target +set(skipRccSources + skipRcc.cpp + skipSource/skipRccBad1.qrc + skipSource/skipRccBad2.qrc + skipSource/skipRccGood.qrc +) +set_property(SOURCE skipSource/skipRccBad1.qrc PROPERTY SKIP_AUTORCC ON) +set_property(SOURCE skipSource/skipRccBad2.qrc PROPERTY SKIP_AUTOGEN ON) +# AUTORCC enabled +add_executable(skipRccA ${skipRccSources}) +set_property(TARGET skipRccA PROPERTY AUTORCC ON) +target_link_libraries(skipRccA ${QT_LIBRARIES}) +# AUTORCC, AUTOUIC and AUTOMOC enabled +add_executable(skipRccB ${skipRccSources}) +set_property(TARGET skipRccB PROPERTY AUTORCC ON) +set_property(TARGET skipRccB PROPERTY AUTOUIC ON) +set_property(TARGET skipRccB PROPERTY AUTOMOC ON) +target_link_libraries(skipRccB ${QT_LIBRARIES}) + # -- Test: AUTOMOC AUTORCC # Source files with the same basename in different subdirectories add_subdirectory(sameName) diff --git a/Tests/QtAutogen/skipMoc.cpp b/Tests/QtAutogen/skipMoc.cpp new file mode 100644 index 0000000..85305f5 --- /dev/null +++ b/Tests/QtAutogen/skipMoc.cpp @@ -0,0 +1,14 @@ + +#include "skipSource/qItemA.hpp" +#include "skipSource/qItemB.hpp" +#include "skipSource/qItemC.hpp" + +int main(int, char**) +{ + QItemA itemA; + QItemA itemB; + QItemA itemC; + + // Fails to link if the symbol is not present. + return 0; +} diff --git a/Tests/QtAutogen/skipRcc.cpp b/Tests/QtAutogen/skipRcc.cpp new file mode 100644 index 0000000..ec57110 --- /dev/null +++ b/Tests/QtAutogen/skipRcc.cpp @@ -0,0 +1,9 @@ + +extern int qInitResources_skipRccGood(); + +int main(int, char**) +{ + // Fails to link if the symbol is not present. + qInitResources_skipRccGood(); + return 0; +} diff --git a/Tests/QtAutogen/skipSource/qItemA.cpp b/Tests/QtAutogen/skipSource/qItemA.cpp new file mode 100644 index 0000000..522c2c7 --- /dev/null +++ b/Tests/QtAutogen/skipSource/qItemA.cpp @@ -0,0 +1,5 @@ +#include "qItemA.hpp" + +void QItemA::go() +{ +} diff --git a/Tests/QtAutogen/skipSource/qItemA.hpp b/Tests/QtAutogen/skipSource/qItemA.hpp new file mode 100644 index 0000000..d295faf --- /dev/null +++ b/Tests/QtAutogen/skipSource/qItemA.hpp @@ -0,0 +1,13 @@ +#ifndef QITEMA_HPP +#define QITEMA_HPP + +#include <QObject> + +class QItemA : public QObject +{ + Q_OBJECT + Q_SLOT + void go(); +}; + +#endif diff --git a/Tests/QtAutogen/skipSource/qItemB.cpp b/Tests/QtAutogen/skipSource/qItemB.cpp new file mode 100644 index 0000000..636e15d --- /dev/null +++ b/Tests/QtAutogen/skipSource/qItemB.cpp @@ -0,0 +1,5 @@ +#include "qItemB.hpp" + +void QItemB::go() +{ +} diff --git a/Tests/QtAutogen/skipSource/qItemB.hpp b/Tests/QtAutogen/skipSource/qItemB.hpp new file mode 100644 index 0000000..1775915 --- /dev/null +++ b/Tests/QtAutogen/skipSource/qItemB.hpp @@ -0,0 +1,13 @@ +#ifndef QITEMB_HPP +#define QITEMB_HPP + +#include <QObject> + +class QItemB : public QObject +{ + Q_OBJECT + Q_SLOT + void go(); +}; + +#endif diff --git a/Tests/QtAutogen/skipSource/qItemC.cpp b/Tests/QtAutogen/skipSource/qItemC.cpp new file mode 100644 index 0000000..700abd6 --- /dev/null +++ b/Tests/QtAutogen/skipSource/qItemC.cpp @@ -0,0 +1,5 @@ +#include "qItemC.hpp" + +void QItemC::go() +{ +} diff --git a/Tests/QtAutogen/skipSource/qItemC.hpp b/Tests/QtAutogen/skipSource/qItemC.hpp new file mode 100644 index 0000000..f06bda2 --- /dev/null +++ b/Tests/QtAutogen/skipSource/qItemC.hpp @@ -0,0 +1,13 @@ +#ifndef QITEMC_HPP +#define QITEMC_HPP + +#include <QObject> + +class QItemC : public QObject +{ + Q_OBJECT + Q_SLOT + void go(); +}; + +#endif diff --git a/Tests/QtAutogen/skipSource/skipRccBad1.qrc b/Tests/QtAutogen/skipSource/skipRccBad1.qrc new file mode 100644 index 0000000..6cbd9ed --- /dev/null +++ b/Tests/QtAutogen/skipSource/skipRccBad1.qrc @@ -0,0 +1,5 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>skipRccGood.cpp</file>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +</qresource> +</RCC> diff --git a/Tests/QtAutogen/skipSource/skipRccBad2.qrc b/Tests/QtAutogen/skipSource/skipRccBad2.qrc new file mode 100644 index 0000000..b32c589 --- /dev/null +++ b/Tests/QtAutogen/skipSource/skipRccBad2.qrc @@ -0,0 +1,5 @@ +<!DOCTYPE RCC><RCC version="1.0">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>< +<qresource> + <file>skipRccGood.cpp</file> +</qresource> +</RCC> diff --git a/Tests/QtAutogen/skipSource/skipRccGood.qrc b/Tests/QtAutogen/skipSource/skipRccGood.qrc new file mode 100644 index 0000000..21a94b0 --- /dev/null +++ b/Tests/QtAutogen/skipSource/skipRccGood.qrc @@ -0,0 +1,6 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>skipRccBad1.qrc</file> + <file>skipRccBad2.qrc</file> +</qresource> +</RCC> diff --git a/Tests/QtAutogen/skipSource/skipUicGen.cpp b/Tests/QtAutogen/skipSource/skipUicGen.cpp new file mode 100644 index 0000000..d2a55a6 --- /dev/null +++ b/Tests/QtAutogen/skipSource/skipUicGen.cpp @@ -0,0 +1,7 @@ + +#include "skipUicGen.hpp" +#include "ui_uigen2.h" + +void skipGen() +{ +} diff --git a/Tests/QtAutogen/skipSource/skipUicGen.hpp b/Tests/QtAutogen/skipSource/skipUicGen.hpp new file mode 100644 index 0000000..3669f0e --- /dev/null +++ b/Tests/QtAutogen/skipSource/skipUicGen.hpp @@ -0,0 +1,8 @@ +#ifndef SKIPUICGEN_HPP +#define SKIPUICGEN_HPP + +#include "ui_uigen1.h" + +void skipGen(); + +#endif diff --git a/Tests/QtAutogen/skipSource/skipUicNoGen1.cpp b/Tests/QtAutogen/skipSource/skipUicNoGen1.cpp new file mode 100644 index 0000000..f591a42 --- /dev/null +++ b/Tests/QtAutogen/skipSource/skipUicNoGen1.cpp @@ -0,0 +1,7 @@ + +#include "skipUicNoGen1.hpp" +#include "ui_nogen2.h" + +void skipNoGen1() +{ +} diff --git a/Tests/QtAutogen/skipSource/skipUicNoGen1.hpp b/Tests/QtAutogen/skipSource/skipUicNoGen1.hpp new file mode 100644 index 0000000..2864695 --- /dev/null +++ b/Tests/QtAutogen/skipSource/skipUicNoGen1.hpp @@ -0,0 +1,8 @@ +#ifndef SKIPUICNOGEN1_H +#define SKIPUICNOGEN1_H + +#include "ui_nogen1.h" + +void skipNoGen1(); + +#endif diff --git a/Tests/QtAutogen/skipSource/skipUicNoGen2.cpp b/Tests/QtAutogen/skipSource/skipUicNoGen2.cpp new file mode 100644 index 0000000..8c1c324 --- /dev/null +++ b/Tests/QtAutogen/skipSource/skipUicNoGen2.cpp @@ -0,0 +1,7 @@ + +#include "skipUicNoGen2.hpp" +#include "ui_nogen2.h" + +void skipNoGen2() +{ +} diff --git a/Tests/QtAutogen/skipSource/skipUicNoGen2.hpp b/Tests/QtAutogen/skipSource/skipUicNoGen2.hpp new file mode 100644 index 0000000..7c38193 --- /dev/null +++ b/Tests/QtAutogen/skipSource/skipUicNoGen2.hpp @@ -0,0 +1,8 @@ +#ifndef SKIPUICNOGEN2_H +#define SKIPUICNOGEN2_H + +#include "ui_nogen1.h" + +void skipNoGen2(); + +#endif diff --git a/Tests/QtAutogen/skipSource/ui_nogen1.h b/Tests/QtAutogen/skipSource/ui_nogen1.h new file mode 100644 index 0000000..a7be52b --- /dev/null +++ b/Tests/QtAutogen/skipSource/ui_nogen1.h @@ -0,0 +1,6 @@ +#ifndef UI_NOGEN1_H +#define UI_NOGEN1_H + +void ui_nogen1(); + +#endif diff --git a/Tests/QtAutogen/skipSource/ui_nogen2.h b/Tests/QtAutogen/skipSource/ui_nogen2.h new file mode 100644 index 0000000..5d547d4 --- /dev/null +++ b/Tests/QtAutogen/skipSource/ui_nogen2.h @@ -0,0 +1,6 @@ +#ifndef UI_NOGEN2_H +#define UI_NOGEN2_H + +void ui_nogen2(); + +#endif
\ No newline at end of file diff --git a/Tests/QtAutogen/skipSource/uigen1.ui b/Tests/QtAutogen/skipSource/uigen1.ui new file mode 100644 index 0000000..fc7cb82 --- /dev/null +++ b/Tests/QtAutogen/skipSource/uigen1.ui @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>UiGen1</class> + <widget class="QWidget" name="UiGen1"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QTreeView" name="treeView"/> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Tests/QtAutogen/skipSource/uigen2.ui b/Tests/QtAutogen/skipSource/uigen2.ui new file mode 100644 index 0000000..01f08d2 --- /dev/null +++ b/Tests/QtAutogen/skipSource/uigen2.ui @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>UiGen2</class> + <widget class="QWidget" name="UiGen2"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QTreeView" name="treeView"/> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Tests/QtAutogen/skipUic.cpp b/Tests/QtAutogen/skipUic.cpp new file mode 100644 index 0000000..0adf011 --- /dev/null +++ b/Tests/QtAutogen/skipUic.cpp @@ -0,0 +1,22 @@ + +#include "skipSource/skipUicGen.hpp" +#include "skipSource/skipUicNoGen1.hpp" +#include "skipSource/skipUicNoGen2.hpp" + +int main(int, char**) +{ + skipGen(); + skipNoGen1(); + skipNoGen2(); + + return 0; +} + +// -- Function definitions +void ui_nogen1() +{ +} + +void ui_nogen2() +{ +} diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index adfd37d..d2465c4 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -345,7 +345,7 @@ if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja") add_RunCMake_test(CompilerLauncher) endif() -add_RunCMake_test_group(CPack "DEB;RPM;TGZ") +add_RunCMake_test_group(CPack "DEB;RPM;7Z;TBZ2;TGZ;TXZ;TZ;ZIP") # add a test to make sure symbols are exported from a shared library # for MSVC compilers CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS property is used add_RunCMake_test(AutoExportDll) diff --git a/Tests/RunCMake/CPack/7Z/Helpers.cmake b/Tests/RunCMake/CPack/7Z/Helpers.cmake new file mode 100644 index 0000000..f256a42 --- /dev/null +++ b/Tests/RunCMake/CPack/7Z/Helpers.cmake @@ -0,0 +1,3 @@ +set(cpack_archive_extension_ "7z") + +include("${CMAKE_CURRENT_LIST_DIR}/../ArchiveCommon/common_helpers.cmake") diff --git a/Tests/RunCMake/CPack/7Z/Prerequirements.cmake b/Tests/RunCMake/CPack/7Z/Prerequirements.cmake new file mode 100644 index 0000000..dbaf682 --- /dev/null +++ b/Tests/RunCMake/CPack/7Z/Prerequirements.cmake @@ -0,0 +1,4 @@ +function(get_test_prerequirements found_var config_file) + file(WRITE "${config_file}" "") + set(${found_var} true PARENT_SCOPE) +endfunction() diff --git a/Tests/RunCMake/CPack/7Z/packaging_COMPONENT_default.cmake b/Tests/RunCMake/CPack/7Z/packaging_COMPONENT_default.cmake new file mode 100644 index 0000000..81a5035 --- /dev/null +++ b/Tests/RunCMake/CPack/7Z/packaging_COMPONENT_default.cmake @@ -0,0 +1 @@ +set(CPACK_ARCHIVE_COMPONENT_INSTALL "ON") diff --git a/Tests/RunCMake/CPack/ArchiveCommon/common_helpers.cmake b/Tests/RunCMake/CPack/ArchiveCommon/common_helpers.cmake new file mode 100644 index 0000000..ce039f5 --- /dev/null +++ b/Tests/RunCMake/CPack/ArchiveCommon/common_helpers.cmake @@ -0,0 +1,62 @@ +set(ALL_FILES_GLOB "*.${cpack_archive_extension_}") + +function(getPackageContent FILE RESULT_VAR) + # TODO for some types this only works because libarchive handles it... (not + # part of for e.g. gnu tar) + execute_process(COMMAND ${CMAKE_COMMAND} -E tar -xtf ${FILE} + OUTPUT_VARIABLE package_content_ + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + + set(${RESULT_VAR} "${package_content_}" PARENT_SCOPE) +endfunction() + +function(getPackageNameGlobexpr NAME COMPONENT VERSION REVISION FILE_NO RESULT_VAR) + if(COMPONENT) + set(COMPONENT "-${COMPONENT}") + endif() + + set(${RESULT_VAR} + "${NAME}-${VERSION}-*${COMPONENT}.${cpack_archive_extension_}" PARENT_SCOPE) +endfunction() + +function(getPackageContentList FILE RESULT_VAR) + getPackageContent("${FILE}" package_content_) + + string(REPLACE "\n" ";" package_content_ "${package_content_}") + foreach(i_ IN LISTS package_content_) + string(REGEX REPLACE "/$" "" result_ "${i_}") + list(APPEND items_ "${result_}") + endforeach() + + set(${RESULT_VAR} "${items_}" PARENT_SCOPE) +endfunction() + +function(toExpectedContentList FILE_NO CONTENT_VAR) + findExpectedFile("${FILE_NO}" "file_") + + # component and monolithic packages differ for some reason by either having + # package filename prefix in path or not + if(PACKAGING_TYPE STREQUAL "MONOLITHIC") + get_filename_component(prefix_ "${file_}" NAME) + # NAME_WE removes everything after the dot and dot is in version so replace instead + string(REPLACE ".${cpack_archive_extension_}" "/" prefix_ "${prefix_}") + else() + unset(prefix_) + endif() + + if(NOT DEFINED TEST_MAIN_INSTALL_PREFIX_PATH) + set(TEST_MAIN_INSTALL_PREFIX_PATH "/usr") + endif() + + unset(filtered_) + foreach(part_ IN LISTS ${CONTENT_VAR}) + string(REGEX REPLACE "^${TEST_MAIN_INSTALL_PREFIX_PATH}(/|$)" "" part_ "${part_}") + + if(part_) + list(APPEND filtered_ "${prefix_}${part_}") + endif() + endforeach() + + set(${CONTENT_VAR} "${filtered_}" PARENT_SCOPE) +endfunction() diff --git a/Tests/RunCMake/CPack/CPackTestHelpers.cmake b/Tests/RunCMake/CPack/CPackTestHelpers.cmake index 89da610..f883c69 100644 --- a/Tests/RunCMake/CPack/CPackTestHelpers.cmake +++ b/Tests/RunCMake/CPack/CPackTestHelpers.cmake @@ -60,7 +60,11 @@ function(run_cpack_test_common_ TEST_NAME types build SUBTEST_SUFFIX source PACK ) foreach(o out err) - if(SUBTEST_SUFFIX AND EXISTS ${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${TEST_TYPE}-${SUBTEST_SUFFIX}-std${o}.txt) + if(SUBTEST_SUFFIX AND EXISTS ${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${TEST_TYPE}-${PACKAGING_TYPE}-${SUBTEST_SUFFIX}-std${o}.txt) + set(RunCMake-std${o}-file "tests/${TEST_NAME}/${TEST_TYPE}-${PACKAGING_TYPE}-${SUBTEST_SUFFIX}-std${o}.txt") + elseif(EXISTS ${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${TEST_TYPE}-${PACKAGING_TYPE}-std${o}.txt) + set(RunCMake-std${o}-file "tests/${TEST_NAME}/${TEST_TYPE}-${PACKAGING_TYPE}-std${o}.txt") + elseif(SUBTEST_SUFFIX AND EXISTS ${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${TEST_TYPE}-${SUBTEST_SUFFIX}-std${o}.txt) set(RunCMake-std${o}-file "tests/${TEST_NAME}/${TEST_TYPE}-${SUBTEST_SUFFIX}-std${o}.txt") elseif(EXISTS ${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${TEST_TYPE}-std${o}.txt) set(RunCMake-std${o}-file "tests/${TEST_NAME}/${TEST_TYPE}-std${o}.txt") diff --git a/Tests/RunCMake/CPack/README.txt b/Tests/RunCMake/CPack/README.txt index f51d254..7c98f69 100644 --- a/Tests/RunCMake/CPack/README.txt +++ b/Tests/RunCMake/CPack/README.txt @@ -155,8 +155,18 @@ VerifyResult.cmake script also automatically prints out standard output and standard error from CPack execution phase that is compared with '<test_name>/<generator_name>-stdout.txt' regular expression and and '<test_name>/<generator_name>-stderr.txt' regular expresson respectively. -NOTE: For subtests generator name can also be suffixed with subtest name and in - such case subtest file is preferred. +NOTE: For subtests generator name can also be suffixed with subtest name and/or + packaging type (MONOLITHIC, COMPONENT, GROUP) and in such cases the + preferences of which file will be used are as follows: + - generator name + packaging type + subtest name + - generator name + packaging type + - generator name + subtest name + - generator name + - default generator + File name format: '<generator_name>-<packaging_type>-<subtest_name>-std<type>.txt' + where <type> can either be 'out' or 'err'. + File name format: '<generator_name>-<packaging_type>-std<type>.txt' + where <type> can either be 'out' or 'err'. File name format: '<generator_name>-<subtest_name>-std<type>.txt' where <type> can either be 'out' or 'err'. NOTE: If none of the comparison files are present then the default generator @@ -223,3 +233,4 @@ To add a new generator we must - if needed add 'default_expected_std<type>.txt' files where <type> is either 'out' or 'err' which will contain default expected output of package generation regular expression. +- add generator to list of other CPack generators in RunCMake/CMakeLists.txt diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index 3077340..ebaf792 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -4,6 +4,7 @@ include(RunCMake) include("${RunCMake_SOURCE_DIR}/CPackTestHelpers.cmake") # run_cpack_test args: TEST_NAME "GENERATORS" RUN_CMAKE_BUILD_STEP "PACKAGING_TYPES" +run_cpack_test(CUSTOM_BINARY_SPEC_FILE "RPM" false "MONOLITHIC;COMPONENT") run_cpack_test(CUSTOM_NAMES "RPM;DEB" true "COMPONENT") run_cpack_test(DEBUGINFO "RPM" true "COMPONENT") run_cpack_test(DEPENDENCIES "RPM;DEB" true "COMPONENT") @@ -15,7 +16,7 @@ run_cpack_test(GENERATE_SHLIBS_LDCONFIG "DEB" true "COMPONENT") run_cpack_test(INSTALL_SCRIPTS "RPM" false "COMPONENT") run_cpack_test(LONG_FILENAMES "DEB" false "MONOLITHIC") run_cpack_test_subtests(MAIN_COMPONENT "invalid;found" "RPM" false "COMPONENT") -run_cpack_test(MINIMAL "RPM;DEB;TGZ" false "MONOLITHIC") +run_cpack_test(MINIMAL "RPM;DEB;7Z;TBZ2;TGZ;TXZ;TZ;ZIP" false "MONOLITHIC;COMPONENT") run_cpack_test_subtests(PACKAGE_CHECKSUM "invalid;MD5;SHA1;SHA224;SHA256;SHA384;SHA512" "TGZ" false "MONOLITHIC") run_cpack_test(PARTIALLY_RELOCATABLE_WARNING "RPM" false "COMPONENT") run_cpack_test(PER_COMPONENT_FIELDS "RPM;DEB" false "COMPONENT") @@ -23,3 +24,4 @@ run_cpack_test_subtests(SINGLE_DEBUGINFO "no_main_component;one_component;one_co run_cpack_source_test(SOURCE_PACKAGE "RPM") run_cpack_test(SUGGESTS "RPM" false "MONOLITHIC") run_cpack_test(USER_FILELIST "RPM" false "MONOLITHIC") +run_cpack_test(MD5SUMS "DEB" false "MONOLITHIC;COMPONENT") diff --git a/Tests/RunCMake/CPack/TBZ2/Helpers.cmake b/Tests/RunCMake/CPack/TBZ2/Helpers.cmake new file mode 100644 index 0000000..292b691 --- /dev/null +++ b/Tests/RunCMake/CPack/TBZ2/Helpers.cmake @@ -0,0 +1,3 @@ +set(cpack_archive_extension_ "tar.bz2") + +include("${CMAKE_CURRENT_LIST_DIR}/../ArchiveCommon/common_helpers.cmake") diff --git a/Tests/RunCMake/CPack/TBZ2/Prerequirements.cmake b/Tests/RunCMake/CPack/TBZ2/Prerequirements.cmake new file mode 100644 index 0000000..dbaf682 --- /dev/null +++ b/Tests/RunCMake/CPack/TBZ2/Prerequirements.cmake @@ -0,0 +1,4 @@ +function(get_test_prerequirements found_var config_file) + file(WRITE "${config_file}" "") + set(${found_var} true PARENT_SCOPE) +endfunction() diff --git a/Tests/RunCMake/CPack/TBZ2/packaging_COMPONENT_default.cmake b/Tests/RunCMake/CPack/TBZ2/packaging_COMPONENT_default.cmake new file mode 100644 index 0000000..81a5035 --- /dev/null +++ b/Tests/RunCMake/CPack/TBZ2/packaging_COMPONENT_default.cmake @@ -0,0 +1 @@ +set(CPACK_ARCHIVE_COMPONENT_INSTALL "ON") diff --git a/Tests/RunCMake/CPack/TGZ/Helpers.cmake b/Tests/RunCMake/CPack/TGZ/Helpers.cmake index 4a194c6..4357a59 100644 --- a/Tests/RunCMake/CPack/TGZ/Helpers.cmake +++ b/Tests/RunCMake/CPack/TGZ/Helpers.cmake @@ -1,62 +1,3 @@ -set(ALL_FILES_GLOB "*.tar.gz") +set(cpack_archive_extension_ "tar.gz") -function(getPackageContent FILE RESULT_VAR) - execute_process(COMMAND ${CMAKE_COMMAND} -E tar -ztvf ${FILE} - OUTPUT_VARIABLE package_content_ - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - - set(${RESULT_VAR} "${package_content_}" PARENT_SCOPE) -endfunction() - -function(getPackageNameGlobexpr NAME COMPONENT VERSION REVISION FILE_NO RESULT_VAR) - if(COMPONENT) - set(COMPONENT "-${COMPONENT}") - endif() - - set(${RESULT_VAR} "${NAME}-${VERSION}-*${COMPONENT}.tar.gz" PARENT_SCOPE) -endfunction() - -function(getPackageContentList FILE RESULT_VAR) - execute_process(COMMAND ${CMAKE_COMMAND} -E tar -ztf ${FILE} - OUTPUT_VARIABLE package_content_ - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - - string(REPLACE "\n" ";" package_content_ "${package_content_}") - foreach(i_ IN LISTS package_content_) - string(REGEX REPLACE "/$" "" result_ "${i_}") - list(APPEND items_ "${result_}") - endforeach() - - set(${RESULT_VAR} "${items_}" PARENT_SCOPE) -endfunction() - -function(toExpectedContentList FILE_NO CONTENT_VAR) - findExpectedFile("${FILE_NO}" "file_") - - # component and monolithic packages differ for some reason by either having - # package filename prefix in path or not - if(PACKAGING_TYPE STREQUAL "MONOLITHIC") - get_filename_component(prefix_ "${file_}" NAME) - # NAME_WE removes everything after the dot and dot is in version so replace instead - string(REPLACE ".tar.gz" "/" prefix_ "${prefix_}") - else() - unset(prefix_) - endif() - - if(NOT DEFINED TEST_MAIN_INSTALL_PREFIX_PATH) - set(TEST_MAIN_INSTALL_PREFIX_PATH "/usr") - endif() - - unset(filtered_) - foreach(part_ IN LISTS ${CONTENT_VAR}) - string(REGEX REPLACE "^${TEST_MAIN_INSTALL_PREFIX_PATH}(/|$)" "" part_ "${part_}") - - if(part_) - list(APPEND filtered_ "${prefix_}${part_}") - endif() - endforeach() - - set(${CONTENT_VAR} "${filtered_}" PARENT_SCOPE) -endfunction() +include("${CMAKE_CURRENT_LIST_DIR}/../ArchiveCommon/common_helpers.cmake") diff --git a/Tests/RunCMake/CPack/TXZ/Helpers.cmake b/Tests/RunCMake/CPack/TXZ/Helpers.cmake new file mode 100644 index 0000000..f390cb4 --- /dev/null +++ b/Tests/RunCMake/CPack/TXZ/Helpers.cmake @@ -0,0 +1,3 @@ +set(cpack_archive_extension_ "tar.xz") + +include("${CMAKE_CURRENT_LIST_DIR}/../ArchiveCommon/common_helpers.cmake") diff --git a/Tests/RunCMake/CPack/TXZ/Prerequirements.cmake b/Tests/RunCMake/CPack/TXZ/Prerequirements.cmake new file mode 100644 index 0000000..dbaf682 --- /dev/null +++ b/Tests/RunCMake/CPack/TXZ/Prerequirements.cmake @@ -0,0 +1,4 @@ +function(get_test_prerequirements found_var config_file) + file(WRITE "${config_file}" "") + set(${found_var} true PARENT_SCOPE) +endfunction() diff --git a/Tests/RunCMake/CPack/TXZ/packaging_COMPONENT_default.cmake b/Tests/RunCMake/CPack/TXZ/packaging_COMPONENT_default.cmake new file mode 100644 index 0000000..81a5035 --- /dev/null +++ b/Tests/RunCMake/CPack/TXZ/packaging_COMPONENT_default.cmake @@ -0,0 +1 @@ +set(CPACK_ARCHIVE_COMPONENT_INSTALL "ON") diff --git a/Tests/RunCMake/CPack/TZ/Helpers.cmake b/Tests/RunCMake/CPack/TZ/Helpers.cmake new file mode 100644 index 0000000..117cd24 --- /dev/null +++ b/Tests/RunCMake/CPack/TZ/Helpers.cmake @@ -0,0 +1,3 @@ +set(cpack_archive_extension_ "tar.Z") + +include("${CMAKE_CURRENT_LIST_DIR}/../ArchiveCommon/common_helpers.cmake") diff --git a/Tests/RunCMake/CPack/TZ/Prerequirements.cmake b/Tests/RunCMake/CPack/TZ/Prerequirements.cmake new file mode 100644 index 0000000..dbaf682 --- /dev/null +++ b/Tests/RunCMake/CPack/TZ/Prerequirements.cmake @@ -0,0 +1,4 @@ +function(get_test_prerequirements found_var config_file) + file(WRITE "${config_file}" "") + set(${found_var} true PARENT_SCOPE) +endfunction() diff --git a/Tests/RunCMake/CPack/TZ/packaging_COMPONENT_default.cmake b/Tests/RunCMake/CPack/TZ/packaging_COMPONENT_default.cmake new file mode 100644 index 0000000..81a5035 --- /dev/null +++ b/Tests/RunCMake/CPack/TZ/packaging_COMPONENT_default.cmake @@ -0,0 +1 @@ +set(CPACK_ARCHIVE_COMPONENT_INSTALL "ON") diff --git a/Tests/RunCMake/CPack/ZIP/Helpers.cmake b/Tests/RunCMake/CPack/ZIP/Helpers.cmake new file mode 100644 index 0000000..3710bcf --- /dev/null +++ b/Tests/RunCMake/CPack/ZIP/Helpers.cmake @@ -0,0 +1,3 @@ +set(cpack_archive_extension_ "zip") + +include("${CMAKE_CURRENT_LIST_DIR}/../ArchiveCommon/common_helpers.cmake") diff --git a/Tests/RunCMake/CPack/ZIP/Prerequirements.cmake b/Tests/RunCMake/CPack/ZIP/Prerequirements.cmake new file mode 100644 index 0000000..dbaf682 --- /dev/null +++ b/Tests/RunCMake/CPack/ZIP/Prerequirements.cmake @@ -0,0 +1,4 @@ +function(get_test_prerequirements found_var config_file) + file(WRITE "${config_file}" "") + set(${found_var} true PARENT_SCOPE) +endfunction() diff --git a/Tests/RunCMake/CPack/ZIP/packaging_COMPONENT_default.cmake b/Tests/RunCMake/CPack/ZIP/packaging_COMPONENT_default.cmake new file mode 100644 index 0000000..81a5035 --- /dev/null +++ b/Tests/RunCMake/CPack/ZIP/packaging_COMPONENT_default.cmake @@ -0,0 +1 @@ +set(CPACK_ARCHIVE_COMPONENT_INSTALL "ON") diff --git a/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/ExpectedFiles.cmake new file mode 100644 index 0000000..694dc00 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/ExpectedFiles.cmake @@ -0,0 +1,9 @@ +set(EXPECTED_FILES_COUNT "1") +set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") + +if(PACKAGING_TYPE STREQUAL "COMPONENT") + set(EXPECTED_FILES_COUNT "2") + set(EXPECTED_FILE_1_COMPONENT "test") + set(EXPECTED_FILE_2_COMPONENT "test2") + set(EXPECTED_FILE_CONTENT_2_LIST "/usr;/usr/bar;/usr/bar/CMakeLists.txt") +endif() diff --git a/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/RPM-COMPONENT-stderr.txt b/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/RPM-COMPONENT-stderr.txt new file mode 100644 index 0000000..e6d86d0 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/RPM-COMPONENT-stderr.txt @@ -0,0 +1,2 @@ +^CPackRPM: Will use USER specified spec file: (/[^/]*)*/CUSTOM_BINARY_SPEC_FILE/custom\.spec\.in +CPackRPM: Will use GENERATED spec file:.*/Tests/RunCMake/RPM/CPack/CUSTOM_BINARY_SPEC_FILE-build/_CPack_Packages/.*/RPM/SPECS/custom_binary_spec_file-test2\.spec$ diff --git a/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/RPM-MONOLITHIC-stderr.txt b/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/RPM-MONOLITHIC-stderr.txt new file mode 100644 index 0000000..d7bb7af --- /dev/null +++ b/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/RPM-MONOLITHIC-stderr.txt @@ -0,0 +1 @@ +CPackRPM: Will use USER specified spec file: (/[^/]*)*/CUSTOM_BINARY_SPEC_FILE/custom\.spec\.in diff --git a/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/custom.spec.in b/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/custom.spec.in new file mode 100644 index 0000000..db0ac6f --- /dev/null +++ b/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/custom.spec.in @@ -0,0 +1,80 @@ +# -*- rpm-spec -*- +BuildRoot: %_topdir/@CPACK_PACKAGE_FILE_NAME@@CPACK_RPM_PACKAGE_COMPONENT_PART_PATH@ +Summary: @CPACK_RPM_PACKAGE_SUMMARY@ +Name: @CPACK_RPM_PACKAGE_NAME@ +Version: @CPACK_RPM_PACKAGE_VERSION@ +Release: @CPACK_RPM_PACKAGE_RELEASE@ +License: @CPACK_RPM_PACKAGE_LICENSE@ +Group: @CPACK_RPM_PACKAGE_GROUP@ +Vendor: @CPACK_RPM_PACKAGE_VENDOR@ + +@TMP_RPM_URL@ +@TMP_RPM_REQUIRES@ +@TMP_RPM_REQUIRES_PRE@ +@TMP_RPM_REQUIRES_POST@ +@TMP_RPM_REQUIRES_PREUN@ +@TMP_RPM_REQUIRES_POSTUN@ +@TMP_RPM_PROVIDES@ +@TMP_RPM_OBSOLETES@ +@TMP_RPM_CONFLICTS@ +@TMP_RPM_SUGGESTS@ +@TMP_RPM_AUTOPROV@ +@TMP_RPM_AUTOREQ@ +@TMP_RPM_AUTOREQPROV@ +@TMP_RPM_BUILDARCH@ +@TMP_RPM_PREFIXES@ + +@TMP_RPM_DEBUGINFO@ + +%define _rpmdir %_topdir/RPMS +%define _srcrpmdir %_topdir/SRPMS +@FILE_NAME_DEFINE@ +%define _unpackaged_files_terminate_build 0 +@TMP_RPM_SPEC_INSTALL_POST@ +@CPACK_RPM_SPEC_MORE_DEFINE@ +@CPACK_RPM_COMPRESSION_TYPE_TMP@ + +%description +@CPACK_RPM_PACKAGE_DESCRIPTION@ + +# This is a shortcutted spec file generated by CMake RPM generator +# we skip _install step because CPack does that for us. +# We do only save CPack installed tree in _prepr +# and then restore it in build. +%prep +mv $RPM_BUILD_ROOT %_topdir/tmpBBroot + +%install +if [ -e $RPM_BUILD_ROOT ]; +then + rm -rf $RPM_BUILD_ROOT +fi +mv %_topdir/tmpBBroot $RPM_BUILD_ROOT + +@TMP_RPM_DEBUGINFO_INSTALL@ + +%clean + +%post +@RPM_SYMLINK_POSTINSTALL@ +@CPACK_RPM_SPEC_POSTINSTALL@ + +%postun +@CPACK_RPM_SPEC_POSTUNINSTALL@ + +%pre +@CPACK_RPM_SPEC_PREINSTALL@ + +%preun +@CPACK_RPM_SPEC_PREUNINSTALL@ + +%files +%defattr(@TMP_DEFAULT_FILE_PERMISSIONS@,@TMP_DEFAULT_USER@,@TMP_DEFAULT_GROUP@,@TMP_DEFAULT_DIR_PERMISSIONS@) +@CPACK_RPM_INSTALL_FILES@ +@CPACK_RPM_ABSOLUTE_INSTALL_FILES@ +@CPACK_RPM_USER_INSTALL_FILES@ + +%changelog +@CPACK_RPM_SPEC_CHANGELOG@ + +@TMP_OTHER_COMPONENTS@ diff --git a/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/test.cmake b/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/test.cmake new file mode 100644 index 0000000..a604863 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/test.cmake @@ -0,0 +1,9 @@ +install(FILES CMakeLists.txt DESTINATION foo COMPONENT test) + +if(PACKAGING_TYPE STREQUAL "MONOLITHIC") + set(CPACK_RPM_USER_BINARY_SPECFILE "${CMAKE_CURRENT_LIST_DIR}/custom.spec.in") +elseif(PACKAGING_TYPE STREQUAL "COMPONENT") + install(FILES CMakeLists.txt DESTINATION bar COMPONENT test2) + set(CPACK_RPM_TEST_USER_BINARY_SPECFILE + "${CMAKE_CURRENT_LIST_DIR}/custom.spec.in") +endif() diff --git a/Tests/RunCMake/CPack/tests/MD5SUMS/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/MD5SUMS/ExpectedFiles.cmake new file mode 100644 index 0000000..6142eb3 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/MD5SUMS/ExpectedFiles.cmake @@ -0,0 +1,2 @@ +set(EXPECTED_FILES_COUNT "1") +set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") diff --git a/Tests/RunCMake/CPack/tests/MD5SUMS/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/MD5SUMS/VerifyResult.cmake new file mode 100644 index 0000000..fbdda9c --- /dev/null +++ b/Tests/RunCMake/CPack/tests/MD5SUMS/VerifyResult.cmake @@ -0,0 +1,3 @@ +set(whitespaces_ "[\t\n\r ]*") +set(md5sums_md5sums "^.* usr/foo/CMakeLists\.txt${whitespaces_}$") +verifyDebControl("${FOUND_FILE_1}" "md5sums" "md5sums") diff --git a/Tests/RunCMake/CPack/tests/MD5SUMS/test.cmake b/Tests/RunCMake/CPack/tests/MD5SUMS/test.cmake new file mode 100644 index 0000000..15c5892 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/MD5SUMS/test.cmake @@ -0,0 +1,5 @@ +install(FILES CMakeLists.txt DESTINATION foo COMPONENT test) + +if(PACKAGING_TYPE STREQUAL "COMPONENT") + set(CPACK_COMPONENTS_ALL test) +endif() diff --git a/Tests/RunCMake/CPack/tests/MINIMAL/test.cmake b/Tests/RunCMake/CPack/tests/MINIMAL/test.cmake index 83ed0f2..15c5892 100644 --- a/Tests/RunCMake/CPack/tests/MINIMAL/test.cmake +++ b/Tests/RunCMake/CPack/tests/MINIMAL/test.cmake @@ -1 +1,5 @@ install(FILES CMakeLists.txt DESTINATION foo COMPONENT test) + +if(PACKAGING_TYPE STREQUAL "COMPONENT") + set(CPACK_COMPONENTS_ALL test) +endif() diff --git a/Tests/RunCMake/ctest_memcheck/DummyAddressLeakSanitizer-result.txt b/Tests/RunCMake/ctest_memcheck/DummyAddressLeakSanitizer-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/ctest_memcheck/DummyAddressLeakSanitizer-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/ctest_memcheck/DummyAddressLeakSanitizer-stderr.txt b/Tests/RunCMake/ctest_memcheck/DummyAddressLeakSanitizer-stderr.txt new file mode 100644 index 0000000..327bd5c --- /dev/null +++ b/Tests/RunCMake/ctest_memcheck/DummyAddressLeakSanitizer-stderr.txt @@ -0,0 +1 @@ +Cannot find memory tester output file: .*/Tests/RunCMake/ctest_memcheck/DummyAddressLeakSanitizer-build/Testing/Temporary/MemoryChecker.1.log\.\* diff --git a/Tests/RunCMake/ctest_memcheck/DummyAddressLeakSanitizer-stdout.txt b/Tests/RunCMake/ctest_memcheck/DummyAddressLeakSanitizer-stdout.txt new file mode 100644 index 0000000..97a8a9b --- /dev/null +++ b/Tests/RunCMake/ctest_memcheck/DummyAddressLeakSanitizer-stdout.txt @@ -0,0 +1,3 @@ +Memory checking results: +Direct leak - 2 +Indirect leak - 1 diff --git a/Tests/RunCMake/ctest_memcheck/RunCMakeTest.cmake b/Tests/RunCMake/ctest_memcheck/RunCMakeTest.cmake index 212bfdb..352a381 100644 --- a/Tests/RunCMake/ctest_memcheck/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_memcheck/RunCMakeTest.cmake @@ -30,22 +30,22 @@ unset(CMAKELISTS_EXTRA_CODE) unset(CTEST_EXTRA_CODE) #----------------------------------------------------------------------------- -# add LeakSanitizer test +# add standalone LeakSanitizer test set(CTEST_EXTRA_CODE -"set(CTEST_MEMORYCHECK_SANITIZER_OPTIONS \"simulate_sanitizer=1 report_bugs=1 history_size=5 exitcode=55\") +"set(CTEST_MEMORYCHECK_SANITIZER_OPTIONS \"simulate_sanitizer=1:report_bugs=1:history_size=5:exitcode=55\") ") set(CMAKELISTS_EXTRA_CODE "add_test(NAME TestSan COMMAND \"${CMAKE_COMMAND}\" -P \"${RunCMake_SOURCE_DIR}/testLeakSanitizer.cmake\") ") -run_mc_test(DummyLeakSanitizer "" -DMEMCHECK_TYPE=AddressSanitizer) +run_mc_test(DummyLeakSanitizer "" -DMEMCHECK_TYPE=LeakSanitizer) unset(CMAKELISTS_EXTRA_CODE) unset(CTEST_EXTRA_CODE) #----------------------------------------------------------------------------- # add AddressSanitizer test set(CTEST_EXTRA_CODE -"set(CTEST_MEMORYCHECK_SANITIZER_OPTIONS \"simulate_sanitizer=1 report_bugs=1 history_size=5 exitcode=55\") +"set(CTEST_MEMORYCHECK_SANITIZER_OPTIONS \"simulate_sanitizer=1:report_bugs=1:history_size=5:exitcode=55\") ") set(CMAKELISTS_EXTRA_CODE "add_test(NAME TestSan COMMAND \"\${CMAKE_COMMAND}\" @@ -56,9 +56,22 @@ unset(CMAKELISTS_EXTRA_CODE) unset(CTEST_EXTRA_CODE) #----------------------------------------------------------------------------- +# add AddressSanitizer/LeakSanitizer test +set(CTEST_EXTRA_CODE +"set(CTEST_MEMORYCHECK_SANITIZER_OPTIONS \"simulate_sanitizer=1:report_bugs=1:history_size=5:exitcode=55\") +") +set(CMAKELISTS_EXTRA_CODE +"add_test(NAME TestSan COMMAND \"${CMAKE_COMMAND}\" +-P \"${RunCMake_SOURCE_DIR}/testAddressLeakSanitizer.cmake\") +") +run_mc_test(DummyAddressLeakSanitizer "" -DMEMCHECK_TYPE=AddressSanitizer) +unset(CMAKELISTS_EXTRA_CODE) +unset(CTEST_EXTRA_CODE) + +#----------------------------------------------------------------------------- # add MemorySanitizer test set(CTEST_EXTRA_CODE -"set(CTEST_MEMORYCHECK_COMMAND_OPTIONS \"simulate_sanitizer=1 report_bugs=1 history_size=5 exitcode=55\") +"set(CTEST_MEMORYCHECK_COMMAND_OPTIONS \"simulate_sanitizer=1:report_bugs=1:history_size=5:exitcode=55\") ") set(CMAKELISTS_EXTRA_CODE "add_test(NAME TestSan COMMAND \"\${CMAKE_COMMAND}\" @@ -151,13 +164,13 @@ unset(CTEST_SUFFIX_CODE) set(CTEST_SUFFIX_CODE "message(\"Defect count: \${defect_count}\")") set(CTEST_MEMCHECK_ARGS "DEFECT_COUNT defect_count") set(CTEST_EXTRA_CODE -"set(CTEST_MEMORYCHECK_SANITIZER_OPTIONS \"simulate_sanitizer=1 report_bugs=1 history_size=5 exitcode=55\") +"set(CTEST_MEMORYCHECK_SANITIZER_OPTIONS \"simulate_sanitizer=1:report_bugs=1:history_size=5:exitcode=55\") ") set(CMAKELISTS_EXTRA_CODE "add_test(NAME TestSan COMMAND \"${CMAKE_COMMAND}\" -P \"${RunCMake_SOURCE_DIR}/testLeakSanitizer.cmake\") ") -run_mc_test(DummyLeakSanitizerPrintDefects "" -DMEMCHECK_TYPE=AddressSanitizer) +run_mc_test(DummyLeakSanitizerPrintDefects "" -DMEMCHECK_TYPE=LeakSanitizer) unset(CMAKELISTS_EXTRA_CODE) unset(CTEST_EXTRA_CODE) unset(CTEST_MEMCHECK_ARGS) diff --git a/Tests/RunCMake/ctest_memcheck/testAddressLeakSanitizer.cmake b/Tests/RunCMake/ctest_memcheck/testAddressLeakSanitizer.cmake new file mode 100644 index 0000000..2a57b11 --- /dev/null +++ b/Tests/RunCMake/ctest_memcheck/testAddressLeakSanitizer.cmake @@ -0,0 +1,47 @@ +# this file simulates a program that has been built with AddressSanitizer +# options + +message("ASAN_OPTIONS = [$ENV{ASAN_OPTIONS}]") +string(REGEX REPLACE ".*log_path=\"([^\"]*)\".*" "\\1" LOG_FILE "$ENV{ASAN_OPTIONS}") +message("LOG_FILE=[${LOG_FILE}]") + +# if we are not asked to simulate AddressSanitizer don't do it +if(NOT "$ENV{ASAN_OPTIONS}]" MATCHES "simulate_sanitizer.1") + return() +endif() + +# clear the log files +file(REMOVE "${LOG_FILE}.2343") +file(REMOVE "${LOG_FILE}.2344") + +# create an error of each type of LeakSanitizer + +file(APPEND "${LOG_FILE}.2343" +"================================================================= +==25308==ERROR: LeakSanitizer: detected memory leaks + +Direct leak of 4360 byte(s) in 1 object(s) allocated from: + #0 0x46c669 in operator new[](unsigned long) (/home/kitware/msan/a.out+0x46c669) + #1 0x4823b4 in main /home/kitware/msan/memcheck.cxx:12 + #2 0x7fa72bee476c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226 + +SUMMARY: AddressSanitizer: 4436 byte(s) leaked in 2 allocation(s). +") +file(APPEND "${LOG_FILE}.2342" +"================================================================= +==25308==ERROR: LeakSanitizer: detected memory leaks + +Direct leak of 76 byte(s) in 1 object(s) allocated from: + #0 0x46c669 in operator new[](unsigned long) (/home/kitware/msan/a.out+0x46c669) + #1 0x4821b8 in foo() /home/kitware/msan/memcheck.cxx:4 + #2 0x4823f2 in main /home/kitware/msan/memcheck.cxx:14 + #3 0x7fa72bee476c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226 + +Indirect leak of 76 byte(s) in 1 object(s) allocated from: + #0 0x46c669 in operator new[](unsigned long) (/home/kitware/msan/a.out+0x46c669) + #1 0x4821b8 in foo() /home/kitware/msan/memcheck.cxx:4 + #2 0x4823f2 in main /home/kitware/msan/memcheck.cxx:14 + #3 0x7fa72bee476c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226 + +SUMMARY: AddressSanitizer: 4436 byte(s) leaked in 2 allocation(s). +") diff --git a/Tests/RunCMake/ctest_memcheck/testLeakSanitizer.cmake b/Tests/RunCMake/ctest_memcheck/testLeakSanitizer.cmake index 02030be..af214c8 100644 --- a/Tests/RunCMake/ctest_memcheck/testLeakSanitizer.cmake +++ b/Tests/RunCMake/ctest_memcheck/testLeakSanitizer.cmake @@ -1,20 +1,20 @@ -# this file simulates a program that has been built with thread sanitizer +# this file simulates a program that has been built with LeakSanitizer # options -message("ASAN_OPTIONS = [$ENV{ASAN_OPTIONS}]") -string(REGEX REPLACE ".*log_path=\"([^\"]*)\".*" "\\1" LOG_FILE "$ENV{ASAN_OPTIONS}") +message("LSAN_OPTIONS = [$ENV{LSAN_OPTIONS}]") +string(REGEX REPLACE ".*log_path=\"([^\"]*)\".*" "\\1" LOG_FILE "$ENV{LSAN_OPTIONS}") message("LOG_FILE=[${LOG_FILE}]") -# if we are not asked to simulate leak sanitizer don't do it -if(NOT "$ENV{ASAN_OPTIONS}]" MATCHES "simulate_sanitizer.1") + +# if we are not asked to simulate LeakSanitizer don't do it +if(NOT "$ENV{LSAN_OPTIONS}]" MATCHES "simulate_sanitizer.1") return() endif() -# clear the log file +# clear the log files file(REMOVE "${LOG_FILE}.2343") file(REMOVE "${LOG_FILE}.2344") -# create an error of each type of thread santizer -# these names come from tsan_report.cc in llvm +# create an error of each type of LeakSanitizer file(APPEND "${LOG_FILE}.2343" "================================================================= @@ -25,7 +25,7 @@ Direct leak of 4360 byte(s) in 1 object(s) allocated from: #1 0x4823b4 in main /home/kitware/msan/memcheck.cxx:12 #2 0x7fa72bee476c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226 -SUMMARY: AddressSanitizer: 4436 byte(s) leaked in 2 allocation(s). +SUMMARY: LeakSanitizer: 4436 byte(s) leaked in 2 allocation(s). ") file(APPEND "${LOG_FILE}.2342" "================================================================= @@ -43,5 +43,5 @@ Indirect leak of 76 byte(s) in 1 object(s) allocated from: #2 0x4823f2 in main /home/kitware/msan/memcheck.cxx:14 #3 0x7fa72bee476c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226 -SUMMARY: AddressSanitizer: 4436 byte(s) leaked in 2 allocation(s). +SUMMARY: LeakSanitizer: 4436 byte(s) leaked in 2 allocation(s). ") diff --git a/Tests/RunCMake/set_property/RunCMakeTest.cmake b/Tests/RunCMake/set_property/RunCMakeTest.cmake index 37c7124..1ddacee 100644 --- a/Tests/RunCMake/set_property/RunCMakeTest.cmake +++ b/Tests/RunCMake/set_property/RunCMakeTest.cmake @@ -6,4 +6,5 @@ run_cmake(COMPILE_OPTIONS) run_cmake(INCLUDE_DIRECTORIES) run_cmake(LINK_LIBRARIES) run_cmake(SOURCES) +run_cmake(TYPE) run_cmake(USER_PROP) diff --git a/Tests/RunCMake/set_property/TYPE-result.txt b/Tests/RunCMake/set_property/TYPE-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/set_property/TYPE-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/set_property/TYPE-stderr.txt b/Tests/RunCMake/set_property/TYPE-stderr.txt new file mode 100644 index 0000000..fbc8653 --- /dev/null +++ b/Tests/RunCMake/set_property/TYPE-stderr.txt @@ -0,0 +1 @@ +TYPE property is read-only diff --git a/Tests/RunCMake/set_property/TYPE.cmake b/Tests/RunCMake/set_property/TYPE.cmake new file mode 100644 index 0000000..8481266 --- /dev/null +++ b/Tests/RunCMake/set_property/TYPE.cmake @@ -0,0 +1,2 @@ +add_custom_target(CustomTarget) +set_property(TARGET CustomTarget PROPERTY TYPE foo) diff --git a/Utilities/cmlibuv/CMakeLists.txt b/Utilities/cmlibuv/CMakeLists.txt index 1b384b5..a8e25ba 100644 --- a/Utilities/cmlibuv/CMakeLists.txt +++ b/Utilities/cmlibuv/CMakeLists.txt @@ -218,8 +218,16 @@ if(CMAKE_SYSTEM_NAME STREQUAL "SunOS") ) list(APPEND uv_defines __EXTENSIONS__ - _XOPEN_SOURCE=500 ) + if(CMAKE_SYSTEM_VERSION STREQUAL "5.10") + list(APPEND uv_defines + _XOPEN_SOURCE=500 + ) + else() + list(APPEND uv_defines + _XOPEN_SOURCE=600 + ) + endif() list(APPEND uv_sources src/unix/sunos.c ) |