diff options
336 files changed, 3131 insertions, 1236 deletions
diff --git a/Auxiliary/CMakeLists.txt b/Auxiliary/CMakeLists.txt index 8eb74b7..53cf2c5 100644 --- a/Auxiliary/CMakeLists.txt +++ b/Auxiliary/CMakeLists.txt @@ -1,4 +1,4 @@ install(DIRECTORY vim/indent vim/syntax DESTINATION ${CMAKE_DATA_DIR}/editors/vim) install(FILES cmake-mode.el DESTINATION ${CMAKE_DATA_DIR}/editors/emacs) -install(FILES cmake.m4 DESTINATION share/aclocal) +install(FILES cmake.m4 DESTINATION ${CMAKE_XDGDATA_DIR}/aclocal) add_subdirectory (bash-completion) diff --git a/Help/command/file.rst b/Help/command/file.rst index 8da46cb..3e669c2 100644 --- a/Help/command/file.rst +++ b/Help/command/file.rst @@ -83,10 +83,12 @@ from the input file. :: - file(<MD5|SHA1|SHA224|SHA256|SHA384|SHA512> <filename> <variable>) + file(<HASH> <filename> <variable>) Compute a cryptographic hash of the content of ``<filename>`` and -store it in a ``<variable>``. +store it in a ``<variable>``. The supported ``<HASH>`` algorithm names +are those listed by the :ref:`string(\<HASH\>) <Supported Hash Algorithms>` +command. ------------------------------------------------------------------------------ @@ -234,8 +236,8 @@ Additional options to ``DOWNLOAD`` are: ``EXPECTED_HASH ALGO=<value>`` Verify that the downloaded content hash matches the expected value, where - ``ALGO`` is one of ``MD5``, ``SHA1``, ``SHA224``, ``SHA256``, ``SHA384``, or - ``SHA512``. If it does not match, the operation fails with an error. + ``ALGO`` is one of the algorithms supported by ``file(<HASH>)``. + If it does not match, the operation fails with an error. ``EXPECTED_MD5 <value>`` Historical short-hand for ``EXPECTED_HASH MD5=<value>``. diff --git a/Help/command/string.rst b/Help/command/string.rst index 8028333..77538f6 100644 --- a/Help/command/string.rst +++ b/Help/command/string.rst @@ -206,15 +206,38 @@ Comparison Compare the strings and store true or false in the output variable. +.. _`Supported Hash Algorithms`: + Hashing ^^^^^^^ :: - string(<MD5|SHA1|SHA224|SHA256|SHA384|SHA512> - <output variable> <input>) + string(<HASH> <output variable> <input>) Compute a cryptographic hash of the input string. +The supported ``<HASH>`` algorithm names are: + +``MD5`` + Message-Digest Algorithm 5, RFC 1321. +``SHA1`` + US Secure Hash Algorithm 1, RFC 3174. +``SHA224`` + US Secure Hash Algorithms, RFC 4634. +``SHA256`` + US Secure Hash Algorithms, RFC 4634. +``SHA384`` + US Secure Hash Algorithms, RFC 4634. +``SHA512`` + US Secure Hash Algorithms, RFC 4634. +``SHA3_224`` + Keccak SHA-3. +``SHA3_256`` + Keccak SHA-3. +``SHA3_384`` + Keccak SHA-3. +``SHA3_512`` + Keccak SHA-3. Generation ^^^^^^^^^^ diff --git a/Help/manual/cmake-buildsystem.7.rst b/Help/manual/cmake-buildsystem.7.rst index 4950fee..2e6a803 100644 --- a/Help/manual/cmake-buildsystem.7.rst +++ b/Help/manual/cmake-buildsystem.7.rst @@ -964,6 +964,8 @@ are: * ``EXPORT_NAME`` * ``IMPORTED`` * ``NAME`` +* ``NO_SYSTEM_FROM_IMPORTED`` +* Properties matching ``IMPORTED_LIBNAME_*`` * Properties matching ``MAP_IMPORTED_CONFIG_*`` ``INTERFACE`` libraries may be installed and exported. Any content they refer diff --git a/Help/manual/cmake-toolchains.7.rst b/Help/manual/cmake-toolchains.7.rst index 74eab2d..64abe9a 100644 --- a/Help/manual/cmake-toolchains.7.rst +++ b/Help/manual/cmake-toolchains.7.rst @@ -387,7 +387,7 @@ Configure use of an Android NDK with the following variables: :variable:`CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION` Set to the version of the NDK toolchain to be selected as the compiler. - If not specified, the latest available GCC toolchain will be used. + If not specified, the default will be the latest available GCC toolchain. :variable:`CMAKE_ANDROID_STL_TYPE` Set to specify which C++ standard library to use. If not specified, diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 93e809a..460c0b5 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -149,6 +149,7 @@ Variables that Change Behavior /variable/CMAKE_INSTALL_DEFAULT_COMPONENT_NAME /variable/CMAKE_INSTALL_MESSAGE /variable/CMAKE_INSTALL_PREFIX + /variable/CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT /variable/CMAKE_LIBRARY_PATH /variable/CMAKE_MFC_FLAG /variable/CMAKE_MODULE_PATH @@ -244,6 +245,7 @@ Variables that Control the Build /variable/CMAKE_ANDROID_NATIVE_LIB_DEPENDENCIES /variable/CMAKE_ANDROID_NATIVE_LIB_DIRECTORIES /variable/CMAKE_ANDROID_NDK + /variable/CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG /variable/CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION /variable/CMAKE_ANDROID_PROCESS_MAX /variable/CMAKE_ANDROID_PROGUARD @@ -354,6 +356,7 @@ Variables for Languages /variable/CMAKE_Fortran_MODDIR_FLAG /variable/CMAKE_Fortran_MODOUT_FLAG /variable/CMAKE_INTERNAL_PLATFORM_ABI + /variable/CMAKE_LANG_ANDROID_TOOLCHAIN_MACHINE /variable/CMAKE_LANG_ANDROID_TOOLCHAIN_PREFIX /variable/CMAKE_LANG_ANDROID_TOOLCHAIN_SUFFIX /variable/CMAKE_LANG_ARCHIVE_APPEND diff --git a/Help/release/dev/add-SHA-3.rst b/Help/release/dev/add-SHA-3.rst new file mode 100644 index 0000000..5743f10 --- /dev/null +++ b/Help/release/dev/add-SHA-3.rst @@ -0,0 +1,4 @@ +add-SHA-3 +--------- + +* CMake functionality using cryptographic hashes now supports SHA-3 algorithms. diff --git a/Help/release/dev/capture-clang-tidy-errors.rst b/Help/release/dev/capture-clang-tidy-errors.rst new file mode 100644 index 0000000..14c32e6 --- /dev/null +++ b/Help/release/dev/capture-clang-tidy-errors.rst @@ -0,0 +1,6 @@ +capture-clang-tidy-errors +------------------------- + +* If a command specified by the :prop_tgt:`<LANG>_CLANG_TIDY` target property + returns non-zero at build time this is now treated as an error instead of + silently ignored. diff --git a/Help/release/dev/imported-interface-no-system.rst b/Help/release/dev/imported-interface-no-system.rst new file mode 100644 index 0000000..3a727cc --- /dev/null +++ b/Help/release/dev/imported-interface-no-system.rst @@ -0,0 +1,5 @@ +imported-interface-no-system +---------------------------- + +* The :prop_tgt:`NO_SYSTEM_FROM_IMPORTED` target property is now supported + on :ref:`Imported <Imported Targets>` :ref:`Interface Libraries`. diff --git a/Help/variable/CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG.rst b/Help/variable/CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG.rst new file mode 100644 index 0000000..207019a --- /dev/null +++ b/Help/variable/CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG.rst @@ -0,0 +1,6 @@ +CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG +------------------------------------ + +When :ref:`Cross Compiling for Android with the NDK`, this variable +provides the NDK's "host tag" used to construct the path to prebuilt +toolchains that run on the host. diff --git a/Help/variable/CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION.rst b/Help/variable/CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION.rst index dff7d64..5ae55d1 100644 --- a/Help/variable/CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION.rst +++ b/Help/variable/CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION.rst @@ -11,3 +11,6 @@ as the compiler. The variable must be set to one of these forms: A toolchain of the requested version will be selected automatically to match the ABI named in the :variable:`CMAKE_ANDROID_ARCH_ABI` variable. + +If not specified, the default will be a value that selects the latest +available GCC toolchain. diff --git a/Help/variable/CMAKE_INSTALL_PREFIX.rst b/Help/variable/CMAKE_INSTALL_PREFIX.rst index 86f1944..7bd87d6 100644 --- a/Help/variable/CMAKE_INSTALL_PREFIX.rst +++ b/Help/variable/CMAKE_INSTALL_PREFIX.rst @@ -6,6 +6,8 @@ Install directory used by :command:`install`. If ``make install`` is invoked or ``INSTALL`` is built, this directory is prepended onto all install directories. This variable defaults to ``/usr/local`` on UNIX and ``c:/Program Files/${PROJECT_NAME}`` on Windows. +See :variable:`CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT` for how a +project might choose its own default. On UNIX one can use the ``DESTDIR`` mechanism in order to relocate the whole installation. ``DESTDIR`` means DESTination DIRectory. It is diff --git a/Help/variable/CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT.rst b/Help/variable/CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT.rst new file mode 100644 index 0000000..2a5842d --- /dev/null +++ b/Help/variable/CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT.rst @@ -0,0 +1,14 @@ +CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT +------------------------------------------- + +CMake sets this variable to a ``TRUE`` value when the +:variable:`CMAKE_INSTALL_PREFIX` has just been initialized to +its default value, typically on the first run of CMake within +a new build tree. This can be used by project code to change +the default without overriding a user-provided value: + +.. code-block:: cmake + + if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "/my/default" CACHE PATH "..." FORCE) + endif() diff --git a/Help/variable/CMAKE_LANG_ANDROID_TOOLCHAIN_MACHINE.rst b/Help/variable/CMAKE_LANG_ANDROID_TOOLCHAIN_MACHINE.rst new file mode 100644 index 0000000..d336364 --- /dev/null +++ b/Help/variable/CMAKE_LANG_ANDROID_TOOLCHAIN_MACHINE.rst @@ -0,0 +1,9 @@ +CMAKE_<LANG>_ANDROID_TOOLCHAIN_MACHINE +-------------------------------------- + +When :ref:`Cross Compiling for Android` this variable contains the +toolchain binutils machine name (e.g. ``gcc -dumpmachine``). The +binutils typically have a ``<machine>-`` prefix on their name. + +See also :variable:`CMAKE_<LANG>_ANDROID_TOOLCHAIN_PREFIX` +and :variable:`CMAKE_<LANG>_ANDROID_TOOLCHAIN_SUFFIX`. diff --git a/Help/variable/CMAKE_LANG_ANDROID_TOOLCHAIN_PREFIX.rst b/Help/variable/CMAKE_LANG_ANDROID_TOOLCHAIN_PREFIX.rst index b51422f..db04af3 100644 --- a/Help/variable/CMAKE_LANG_ANDROID_TOOLCHAIN_PREFIX.rst +++ b/Help/variable/CMAKE_LANG_ANDROID_TOOLCHAIN_PREFIX.rst @@ -4,7 +4,8 @@ CMAKE_<LANG>_ANDROID_TOOLCHAIN_PREFIX When :ref:`Cross Compiling for Android` this variable contains the absolute path prefixing the toolchain GNU compiler and its binutils. -See also :variable:`CMAKE_<LANG>_ANDROID_TOOLCHAIN_SUFFIX`. +See also :variable:`CMAKE_<LANG>_ANDROID_TOOLCHAIN_SUFFIX` +and :variable:`CMAKE_<LANG>_ANDROID_TOOLCHAIN_MACHINE`. For example, the path to the linker is:: diff --git a/Help/variable/CMAKE_LANG_ANDROID_TOOLCHAIN_SUFFIX.rst b/Help/variable/CMAKE_LANG_ANDROID_TOOLCHAIN_SUFFIX.rst index a4af640..159eb22 100644 --- a/Help/variable/CMAKE_LANG_ANDROID_TOOLCHAIN_SUFFIX.rst +++ b/Help/variable/CMAKE_LANG_ANDROID_TOOLCHAIN_SUFFIX.rst @@ -4,4 +4,5 @@ CMAKE_<LANG>_ANDROID_TOOLCHAIN_SUFFIX When :ref:`Cross Compiling for Android` this variable contains the host platform suffix of the toolchain GNU compiler and its binutils. -See also :variable:`CMAKE_<LANG>_ANDROID_TOOLCHAIN_PREFIX`. +See also :variable:`CMAKE_<LANG>_ANDROID_TOOLCHAIN_PREFIX` +and :variable:`CMAKE_<LANG>_ANDROID_TOOLCHAIN_MACHINE`. diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake index cee1914..4e7546b 100644 --- a/Modules/CPack.cmake +++ b/Modules/CPack.cmake @@ -126,7 +126,9 @@ # # ${CPACK_PACKAGE_FILE_NAME}.${CPACK_PACKAGE_CHECKSUM} # -# Current supported alogorithms: MD5|SHA1|SHA224|SHA256|SHA384|SHA512. +# Supported algorithms are those listed by the +# :ref:`string(\<HASH\>) <Supported Hash Algorithms>` +# command. # # .. variable:: CPACK_PROJECT_CONFIG_FILE # diff --git a/Modules/Compiler/ARMCC.cmake b/Modules/Compiler/ARMCC.cmake index 2ec75c3..250a8f4 100644 --- a/Modules/Compiler/ARMCC.cmake +++ b/Modules/Compiler/ARMCC.cmake @@ -28,6 +28,7 @@ macro(__compiler_armcc lang) set(CMAKE_${lang}_OUTPUT_EXTENSION ".o") set(CMAKE_${lang}_OUTPUT_EXTENSION_REPLACE 1) + set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "--via=") set(CMAKE_${lang}_LINK_EXECUTABLE "<CMAKE_LINKER> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> <OBJECTS> -o <TARGET> --list <TARGET_BASE>.map") set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "<CMAKE_AR> --create -cr <TARGET> <LINK_FLAGS> <OBJECTS>") diff --git a/Modules/ExternalData.cmake b/Modules/ExternalData.cmake index 07cd114..873f88d 100644 --- a/Modules/ExternalData.cmake +++ b/Modules/ExternalData.cmake @@ -279,6 +279,10 @@ The following hash algorithms are supported:: SHA256 .sha256 US Secure Hash Algorithms, RFC 4634 SHA384 .sha384 US Secure Hash Algorithms, RFC 4634 SHA512 .sha512 US Secure Hash Algorithms, RFC 4634 + SHA3_224 .sha3-224 Keccak SHA-3 + SHA3_256 .sha3-256 Keccak SHA-3 + SHA3_384 .sha3-384 Keccak SHA-3 + SHA3_512 .sha3-512 Keccak SHA-3 Note that the hashes are used only for unique data identification and download verification. @@ -508,8 +512,8 @@ endfunction() #----------------------------------------------------------------------------- # Private helper interface -set(_ExternalData_REGEX_ALGO "MD5|SHA1|SHA224|SHA256|SHA384|SHA512") -set(_ExternalData_REGEX_EXT "md5|sha1|sha224|sha256|sha384|sha512") +set(_ExternalData_REGEX_ALGO "MD5|SHA1|SHA224|SHA256|SHA384|SHA512|SHA3_224|SHA3_256|SHA3_384|SHA3_512") +set(_ExternalData_REGEX_EXT "md5|sha1|sha224|sha256|sha384|sha512|sha3-224|sha3-256|sha3-384|sha3-512") set(_ExternalData_SELF "${CMAKE_CURRENT_LIST_FILE}") get_filename_component(_ExternalData_SELF_DIR "${_ExternalData_SELF}" PATH) @@ -1082,6 +1086,7 @@ if("${ExternalData_ACTION}" STREQUAL "fetch") if("${ext}" MATCHES "^\\.(${_ExternalData_REGEX_EXT})$") string(TOUPPER "${CMAKE_MATCH_1}" algo) + string(REPLACE "-" "_" algo "${algo}") else() message(FATAL_ERROR "Unknown hash algorithm extension \"${ext}\"") endif() diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 1ba4a8f..a0f731c 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -427,7 +427,7 @@ if(_ep_func) endif() # Save regex matching supported hash algorithm names. -set(_ep_hash_algos "MD5|SHA1|SHA224|SHA256|SHA384|SHA512") +set(_ep_hash_algos "MD5|SHA1|SHA224|SHA256|SHA384|SHA512|SHA3_224|SHA3_256|SHA3_384|SHA3_512") set(_ep_hash_regex "^(${_ep_hash_algos})=([0-9A-Fa-f]+)$") set(_ExternalProject_SELF "${CMAKE_CURRENT_LIST_FILE}") @@ -1245,87 +1245,84 @@ endfunction() function(_ep_get_build_command name step cmd_var) - set(cmd "${${cmd_var}}") - if(NOT cmd) - set(args) - _ep_get_configure_command_id(${name} cfg_cmd_id) - if(cfg_cmd_id STREQUAL "cmake") - # CMake project. Select build command based on generator. - get_target_property(cmake_generator ${name} _EP_CMAKE_GENERATOR) - if("${CMAKE_GENERATOR}" MATCHES "Make" AND - ("${cmake_generator}" MATCHES "Make" OR NOT cmake_generator)) - # The project uses the same Makefile generator. Use recursive make. - set(cmd "$(MAKE)") - if(step STREQUAL "INSTALL") - set(args install) - endif() - if("x${step}x" STREQUAL "xTESTx") - set(args test) - endif() - else() - # Drive the project with "cmake --build". - get_target_property(cmake_command ${name} _EP_CMAKE_COMMAND) - if(cmake_command) - set(cmd "${cmake_command}") - else() - set(cmd "${CMAKE_COMMAND}") - endif() - set(args --build ".") - if(CMAKE_CONFIGURATION_TYPES) - if (CMAKE_CFG_INTDIR AND - NOT CMAKE_CFG_INTDIR STREQUAL "." AND - NOT CMAKE_CFG_INTDIR MATCHES "\\$") - # CMake 3.4 and below used the CMAKE_CFG_INTDIR placeholder value - # provided by multi-configuration generators. Some projects were - # taking advantage of that undocumented implementation detail to - # specify a specific configuration here. They should use - # BUILD_COMMAND to change the default command instead, but for - # compatibility honor the value. - set(config ${CMAKE_CFG_INTDIR}) - message(AUTHOR_WARNING "CMAKE_CFG_INTDIR should not be set by project code.\n" - "To get a non-default build command, use the BUILD_COMMAND option.") - else() - set(config $<CONFIG>) - endif() - list(APPEND args --config ${config}) - endif() - if(step STREQUAL "INSTALL") - list(APPEND args --target install) - endif() - # But for "TEST" drive the project with corresponding "ctest". - if("x${step}x" STREQUAL "xTESTx") - string(REGEX REPLACE "^(.*/)cmake([^/]*)$" "\\1ctest\\2" cmd "${cmd}") - set(args "") - if(CMAKE_CONFIGURATION_TYPES) - list(APPEND args -C ${config}) - endif() - endif() + set(cmd "") + set(args) + _ep_get_configure_command_id(${name} cfg_cmd_id) + if(cfg_cmd_id STREQUAL "cmake") + # CMake project. Select build command based on generator. + get_target_property(cmake_generator ${name} _EP_CMAKE_GENERATOR) + if("${CMAKE_GENERATOR}" MATCHES "Make" AND + ("${cmake_generator}" MATCHES "Make" OR NOT cmake_generator)) + # The project uses the same Makefile generator. Use recursive make. + set(cmd "$(MAKE)") + if(step STREQUAL "INSTALL") + set(args install) + endif() + if("x${step}x" STREQUAL "xTESTx") + set(args test) endif() else() - # Non-CMake project. Guess "make" and "make install" and "make test". - if("${CMAKE_GENERATOR}" MATCHES "Makefiles") - # Try to get the parallel arguments - set(cmd "$(MAKE)") + # Drive the project with "cmake --build". + get_target_property(cmake_command ${name} _EP_CMAKE_COMMAND) + if(cmake_command) + set(cmd "${cmake_command}") else() - set(cmd "make") + set(cmd "${CMAKE_COMMAND}") + endif() + set(args --build ".") + if(CMAKE_CONFIGURATION_TYPES) + if (CMAKE_CFG_INTDIR AND + NOT CMAKE_CFG_INTDIR STREQUAL "." AND + NOT CMAKE_CFG_INTDIR MATCHES "\\$") + # CMake 3.4 and below used the CMAKE_CFG_INTDIR placeholder value + # provided by multi-configuration generators. Some projects were + # taking advantage of that undocumented implementation detail to + # specify a specific configuration here. They should use + # BUILD_COMMAND to change the default command instead, but for + # compatibility honor the value. + set(config ${CMAKE_CFG_INTDIR}) + message(AUTHOR_WARNING "CMAKE_CFG_INTDIR should not be set by project code.\n" + "To get a non-default build command, use the BUILD_COMMAND option.") + else() + set(config $<CONFIG>) + endif() + list(APPEND args --config ${config}) endif() if(step STREQUAL "INSTALL") - set(args install) + list(APPEND args --target install) endif() + # But for "TEST" drive the project with corresponding "ctest". if("x${step}x" STREQUAL "xTESTx") - set(args test) + string(REGEX REPLACE "^(.*/)cmake([^/]*)$" "\\1ctest\\2" cmd "${cmd}") + set(args "") + if(CMAKE_CONFIGURATION_TYPES) + list(APPEND args -C ${config}) + endif() endif() endif() - - # Use user-specified arguments instead of default arguments, if any. - get_property(have_args TARGET ${name} PROPERTY _EP_${step}_ARGS SET) - if(have_args) - get_target_property(args ${name} _EP_${step}_ARGS) + else() + # Non-CMake project. Guess "make" and "make install" and "make test". + if("${CMAKE_GENERATOR}" MATCHES "Makefiles") + # Try to get the parallel arguments + set(cmd "$(MAKE)") + else() + set(cmd "make") endif() + if(step STREQUAL "INSTALL") + set(args install) + endif() + if("x${step}x" STREQUAL "xTESTx") + set(args test) + endif() + endif() - list(APPEND cmd ${args}) + # Use user-specified arguments instead of default arguments, if any. + get_property(have_args TARGET ${name} PROPERTY _EP_${step}_ARGS SET) + if(have_args) + get_target_property(args ${name} _EP_${step}_ARGS) endif() + list(APPEND cmd ${args}) set(${cmd_var} "${cmd}" PARENT_SCOPE) endfunction() @@ -2165,12 +2162,12 @@ Update to Mercurial >= 2.1.1. ${uses_terminal} ) - if(always AND update_disconnected) + if(update_disconnected) _ep_get_step_stampfile(${name} skip-update skip-update_stamp_file) string(REPLACE "Performing" "Skipping" comment "${comment}") ExternalProject_Add_Step(${name} skip-update COMMENT ${comment} - ALWAYS 1 + ALWAYS ${always} EXCLUDE_FROM_MAIN 1 WORKING_DIRECTORY ${work_dir} DEPENDEES download diff --git a/Modules/FindBISON.cmake b/Modules/FindBISON.cmake index 5de7a39..d40b806 100644 --- a/Modules/FindBISON.cmake +++ b/Modules/FindBISON.cmake @@ -228,7 +228,7 @@ if(BISON_EXECUTABLE) list(APPEND BISON_TARGET_outputs "${BISON_TARGET_output_header}") add_custom_command(OUTPUT ${BISON_TARGET_outputs} - ${BISON_TARGET_verbose_file} + ${BISON_TARGET_extraoutputs} COMMAND ${BISON_EXECUTABLE} ${BISON_TARGET_cmdopt} -o ${BisonOutput} ${BisonInput} VERBATIM DEPENDS ${BisonInput} diff --git a/Modules/Platform/Android/Determine-Compiler-NDK.cmake b/Modules/Platform/Android/Determine-Compiler-NDK.cmake index 953bc85..d983dd6 100644 --- a/Modules/Platform/Android/Determine-Compiler-NDK.cmake +++ b/Modules/Platform/Android/Determine-Compiler-NDK.cmake @@ -52,6 +52,7 @@ unset(_ANDROID_CONFIG_MK_PATTERNS) # Find the newest toolchain version matching the ABI. set(_ANDROID_TOOL_NAME "") set(_ANDROID_TOOL_VERS 0) +set(_ANDROID_TOOL_VERS_NDK "") set(_ANDROID_TOOL_SETUP_MK "") foreach(config_mk IN LISTS _ANDROID_CONFIG_MKS) # Check that the toolchain matches the ABI. @@ -62,18 +63,21 @@ foreach(config_mk IN LISTS _ANDROID_CONFIG_MKS) unset(_ANDROID_TOOL_ABIS) # Check the version. - if("${config_mk}" MATCHES [[/([^/]+-(clang)?([0-9]\.[0-9]|))/config.mk$]]) + if("${config_mk}" MATCHES [[/([^/]+-((clang)?([0-9]\.[0-9]|)))/config.mk$]]) set(_ANDROID_CUR_NAME "${CMAKE_MATCH_1}") - set(_ANDROID_CUR_VERS "${CMAKE_MATCH_3}") + set(_ANDROID_CUR_VERS "${CMAKE_MATCH_4}") + set(_ANDROID_CUR_VERS_NDK "${CMAKE_MATCH_2}") if(_ANDROID_TOOL_VERS STREQUAL "") # already the latest possible elseif(_ANDROID_CUR_VERS STREQUAL "" OR _ANDROID_CUR_VERS VERSION_GREATER _ANDROID_TOOL_VERS) set(_ANDROID_TOOL_NAME "${_ANDROID_CUR_NAME}") set(_ANDROID_TOOL_VERS "${_ANDROID_CUR_VERS}") + set(_ANDROID_TOOL_VERS_NDK "${_ANDROID_CUR_VERS_NDK}") string(REPLACE "/config.mk" "/setup.mk" _ANDROID_TOOL_SETUP_MK "${config_mk}") endif() unset(_ANDROID_CUR_TOOL) unset(_ANDROID_CUR_VERS) + unset(_ANDROID_CUR_VERS_NDK) endif() endforeach() @@ -206,10 +210,17 @@ endif() # Help CMakeFindBinUtils locate things. set(_CMAKE_TOOLCHAIN_PREFIX "${_ANDROID_TOOL_PREFIX}") +set(_ANDROID_TOOL_NDK_TOOLCHAIN_HOST_TAG "${_ANDROID_HOST_DIR}") +set(_ANDROID_TOOL_NDK_TOOLCHAIN_VERSION "${_ANDROID_TOOL_VERS_NDK}") + +# _ANDROID_TOOL_PREFIX should now match `gcc -dumpmachine`. +string(REGEX REPLACE "-$" "" _ANDROID_TOOL_C_TOOLCHAIN_MACHINE "${_ANDROID_TOOL_PREFIX}") + set(_ANDROID_TOOL_C_TOOLCHAIN_VERSION "${_ANDROID_TOOL_VERS}") set(_ANDROID_TOOL_C_TOOLCHAIN_PREFIX "${CMAKE_ANDROID_NDK}/toolchains/${_ANDROID_TOOL_NAME}/prebuilt/${_ANDROID_HOST_DIR}/bin/${_ANDROID_TOOL_PREFIX}") set(_ANDROID_TOOL_C_TOOLCHAIN_SUFFIX "${_ANDROID_HOST_EXT}") +set(_ANDROID_TOOL_CXX_TOOLCHAIN_MACHINE "${_ANDROID_TOOL_C_TOOLCHAIN_MACHINE}") set(_ANDROID_TOOL_CXX_TOOLCHAIN_VERSION "${_ANDROID_TOOL_C_TOOLCHAIN_VERSION}") set(_ANDROID_TOOL_CXX_TOOLCHAIN_PREFIX "${_ANDROID_TOOL_C_TOOLCHAIN_PREFIX}") set(_ANDROID_TOOL_CXX_TOOLCHAIN_SUFFIX "${_ANDROID_TOOL_C_TOOLCHAIN_SUFFIX}") @@ -231,6 +242,7 @@ endif() if(CMAKE_ANDROID_NDK_TOOLCHAIN_DEBUG) message(STATUS "_ANDROID_TOOL_NAME=${_ANDROID_TOOL_NAME}") message(STATUS "_ANDROID_TOOL_VERS=${_ANDROID_TOOL_VERS}") + message(STATUS "_ANDROID_TOOL_VERS_NDK=${_ANDROID_TOOL_VERS_NDK}") message(STATUS "_ANDROID_TOOL_PREFIX=${_ANDROID_TOOL_PREFIX}") message(STATUS "_ANDROID_TOOL_CLANG_NAME=${_ANDROID_TOOL_CLANG_NAME}") message(STATUS "_ANDROID_TOOL_CLANG_VERS=${_ANDROID_TOOL_CLANG_VERS}") @@ -239,6 +251,7 @@ endif() unset(_ANDROID_TOOL_NAME) unset(_ANDROID_TOOL_VERS) +unset(_ANDROID_TOOL_VERS_NDK) unset(_ANDROID_TOOL_PREFIX) unset(_ANDROID_TOOL_CLANG_NAME) unset(_ANDROID_TOOL_CLANG_VERS) diff --git a/Modules/Platform/Android/Determine-Compiler-Standalone.cmake b/Modules/Platform/Android/Determine-Compiler-Standalone.cmake index 6393105..4c1ac1f 100644 --- a/Modules/Platform/Android/Determine-Compiler-Standalone.cmake +++ b/Modules/Platform/Android/Determine-Compiler-Standalone.cmake @@ -22,6 +22,9 @@ endif() # Help CMakeFindBinUtils locate things. set(_CMAKE_TOOLCHAIN_PREFIX "${_ANDROID_TOOL_PREFIX}") +# _ANDROID_TOOL_PREFIX should now match `gcc -dumpmachine`. +string(REGEX REPLACE "-$" "" _ANDROID_TOOL_C_TOOLCHAIN_MACHINE "${_ANDROID_TOOL_PREFIX}") + execute_process( COMMAND "${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}/bin/${_ANDROID_TOOL_PREFIX}gcc${_ANDROID_HOST_EXT}" -dumpversion OUTPUT_VARIABLE _gcc_version @@ -42,6 +45,7 @@ endif() set(_ANDROID_TOOL_C_TOOLCHAIN_PREFIX "${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}/bin/${_ANDROID_TOOL_PREFIX}") set(_ANDROID_TOOL_C_TOOLCHAIN_SUFFIX "${_ANDROID_HOST_EXT}") +set(_ANDROID_TOOL_CXX_TOOLCHAIN_MACHINE "${_ANDROID_TOOL_C_TOOLCHAIN_MACHINE}") set(_ANDROID_TOOL_CXX_TOOLCHAIN_VERSION "${_ANDROID_TOOL_C_TOOLCHAIN_VERSION}") set(_ANDROID_TOOL_CXX_TOOLCHAIN_PREFIX "${_ANDROID_TOOL_C_TOOLCHAIN_PREFIX}") set(_ANDROID_TOOL_CXX_TOOLCHAIN_SUFFIX "${_ANDROID_TOOL_C_TOOLCHAIN_SUFFIX}") @@ -57,3 +61,6 @@ else() set(_ANDROID_TOOL_CXX_COMPILER "${_ANDROID_TOOL_CXX_TOOLCHAIN_PREFIX}g++${_ANDROID_TOOL_CXX_TOOLCHAIN_SUFFIX}") set(_ANDROID_TOOL_CXX_COMPILER_EXTERNAL_TOOLCHAIN "") endif() + +set(_ANDROID_TOOL_NDK_TOOLCHAIN_HOST_TAG "") +set(_ANDROID_TOOL_NDK_TOOLCHAIN_VERSION "") diff --git a/Modules/Platform/Android/Determine-Compiler.cmake b/Modules/Platform/Android/Determine-Compiler.cmake index 2fd2c4a..a03ebcc 100644 --- a/Modules/Platform/Android/Determine-Compiler.cmake +++ b/Modules/Platform/Android/Determine-Compiler.cmake @@ -40,12 +40,16 @@ if(CMAKE_ANDROID_NDK) elseif(CMAKE_ANDROID_STANDALONE_TOOLCHAIN) include(Platform/Android/Determine-Compiler-Standalone) else() + set(_ANDROID_TOOL_NDK_TOOLCHAIN_HOST_TAG "") + set(_ANDROID_TOOL_NDK_TOOLCHAIN_VERSION "") set(_ANDROID_TOOL_C_COMPILER "") + set(_ANDROID_TOOL_C_TOOLCHAIN_MACHINE "") set(_ANDROID_TOOL_C_TOOLCHAIN_VERSION "") set(_ANDROID_TOOL_C_COMPILER_EXTERNAL_TOOLCHAIN "") set(_ANDROID_TOOL_C_TOOLCHAIN_PREFIX "") set(_ANDROID_TOOL_C_TOOLCHAIN_SUFFIX "") set(_ANDROID_TOOL_CXX_COMPILER "") + set(_ANDROID_TOOL_CXX_TOOLCHAIN_MACHINE "") set(_ANDROID_TOOL_CXX_TOOLCHAIN_VERSION "") set(_ANDROID_TOOL_CXX_COMPILER_EXTERNAL_TOOLCHAIN "") set(_ANDROID_TOOL_CXX_TOOLCHAIN_PREFIX "") @@ -61,6 +65,9 @@ macro(__android_determine_compiler lang) # Save the Android-specific information in CMake${lang}Compiler.cmake. set(CMAKE_${lang}_COMPILER_CUSTOM_CODE " +set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG \"${_ANDROID_TOOL_NDK_TOOLCHAIN_HOST_TAG}\") +set(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION \"${_ANDROID_TOOL_NDK_TOOLCHAIN_VERSION}\") +set(CMAKE_${lang}_ANDROID_TOOLCHAIN_MACHINE \"${_ANDROID_TOOL_${lang}_TOOLCHAIN_MACHINE}\") set(CMAKE_${lang}_ANDROID_TOOLCHAIN_VERSION \"${_ANDROID_TOOL_${lang}_TOOLCHAIN_VERSION}\") set(CMAKE_${lang}_COMPILER_EXTERNAL_TOOLCHAIN \"${_ANDROID_TOOL_${lang}_COMPILER_EXTERNAL_TOOLCHAIN}\") set(CMAKE_${lang}_ANDROID_TOOLCHAIN_PREFIX \"${_ANDROID_TOOL_${lang}_TOOLCHAIN_PREFIX}\") diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake index d72ec66..f506500 100644 --- a/Modules/Platform/Windows-MSVC.cmake +++ b/Modules/Platform/Windows-MSVC.cmake @@ -285,13 +285,13 @@ macro(__windows_compiler_msvc lang) # note: MSVC 14 2015 Update 1 sets -fno-ms-compatibility by default, but this does not allow one to compile many projects # that include MS's own headers. CMake itself is affected project too. string(APPEND CMAKE_${lang}_FLAGS_INIT " ${_PLATFORM_DEFINES}${_PLATFORM_DEFINES_${lang}} -fms-extensions -fms-compatibility -D_WINDOWS -Wall${_FLAGS_${lang}}") - string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -D_DEBUG /MDd -gline-tables-only -fno-inline -O0 ${_RTC1}") + string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " /MDd -gline-tables-only -fno-inline -O0 ${_RTC1}") string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " /MD -O2 -DNDEBUG") string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " /MD -gline-tables-only -O2 -fno-inline -DNDEBUG") string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " /MD -DNDEBUG") # TODO: Add '-Os' once VS generator maps it properly for Clang else() string(APPEND CMAKE_${lang}_FLAGS_INIT " ${_PLATFORM_DEFINES}${_PLATFORM_DEFINES_${lang}} /D_WINDOWS /W3${_FLAGS_${lang}}") - string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " /D_DEBUG /MDd /Zi /Ob0 /Od ${_RTC1}") + string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " /MDd /Zi /Ob0 /Od ${_RTC1}") string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " /MD /O2 /Ob2 /DNDEBUG") string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " /MD /Zi /O2 /Ob1 /DNDEBUG") string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " /MD /O1 /Ob1 /DNDEBUG") diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake index 0e00506..c5912f8 100644 --- a/Modules/UseSWIG.cmake +++ b/Modules/UseSWIG.cmake @@ -10,7 +10,7 @@ # :: # # SWIG_ADD_LIBRARY(<name> -# [TYPE <SHARED|MODULE|STATIC>] +# [TYPE <SHARED|MODULE|STATIC|USE_BUILD_SHARED_LIBS>] # LANGUAGE <language> # SOURCES <file>... # ) @@ -248,6 +248,8 @@ macro(SWIG_ADD_LIBRARY name) if(NOT DEFINED _SAM_TYPE) set(_SAM_TYPE MODULE) + elseif("${_SAM_TYPE}" STREQUAL "USE_BUILD_SHARED_LIBS") + unset(_SAM_TYPE) endif() swig_module_initialize(${name} ${_SAM_LANGUAGE}) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index e74a032..f7e0944 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -332,6 +332,8 @@ set(SRCS cmOrderDirectories.h cmPolicies.h cmPolicies.cxx + cmProcessOutput.cxx + cmProcessOutput.h cmProcessTools.cxx cmProcessTools.h cmProperty.cxx @@ -634,6 +636,9 @@ set(SRCS cm_codecvt.cxx ) +SET_PROPERTY(SOURCE cmProcessOutput.cxx APPEND PROPERTY COMPILE_DEFINITIONS + KWSYS_ENCODING_DEFAULT_CODEPAGE=${KWSYS_ENCODING_DEFAULT_CODEPAGE}) + # Kdevelop only works on UNIX and not windows if(UNIX) set(SRCS ${SRCS} cmGlobalKdevelopGenerator.cxx) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 6bee953..3086639 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 20161114) +set(CMake_VERSION_PATCH 20161129) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.cxx b/Source/CPack/IFW/cmCPackIFWInstaller.cxx index 0098a4b..ba3248f 100644 --- a/Source/CPack/IFW/cmCPackIFWInstaller.cxx +++ b/Source/CPack/IFW/cmCPackIFWInstaller.cxx @@ -2,6 +2,11 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCPackIFWInstaller.h" +#include <cmConfigure.h> +#include <sstream> +#include <stddef.h> +#include <utility> + #include "CPack/cmCPackGenerator.h" #include "CPack/cmCPackLog.h" #include "cmCPackIFWGenerator.h" @@ -12,9 +17,6 @@ #include "cmXMLParser.h" #include "cmXMLWriter.h" -#include <cmConfigure.h> -#include <utility> - #ifdef cmCPackLogger #undef cmCPackLogger #endif diff --git a/Source/CPack/OSXScriptLauncher.cxx b/Source/CPack/OSXScriptLauncher.cxx index 6eb4a6c..b159e64 100644 --- a/Source/CPack/OSXScriptLauncher.cxx +++ b/Source/CPack/OSXScriptLauncher.cxx @@ -3,8 +3,10 @@ #include <cmsys/FStream.hxx> #include <cmsys/Process.h> #include <cmsys/SystemTools.hxx> - #include <iostream> +#include <stddef.h> +#include <string> +#include <vector> #include <CoreFoundation/CoreFoundation.h> diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 0c4f573..2bccf2e 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -4,6 +4,7 @@ #include <CPack/cmCPackComponentGroup.h> #include <CPack/cmCPackLog.h> +#include <algorithm> #include <cmCryptoHash.h> #include <cmGeneratedFileStream.h> #include <cmInstalledFile.h> diff --git a/Source/CPack/WiX/cmWIXRichTextFormatWriter.h b/Source/CPack/WiX/cmWIXRichTextFormatWriter.h index b535979..a3c8394 100644 --- a/Source/CPack/WiX/cmWIXRichTextFormatWriter.h +++ b/Source/CPack/WiX/cmWIXRichTextFormatWriter.h @@ -5,9 +5,8 @@ #include <cmConfigure.h> -#include "cmStandardIncludes.h" - #include <cmsys/FStream.hxx> +#include <string> /** \class cmWIXRichtTextFormatWriter * \brief Helper class to generate Rich Text Format (RTF) documents diff --git a/Source/CPack/cmCPackBundleGenerator.cxx b/Source/CPack/cmCPackBundleGenerator.cxx index 61d0127..d538901 100644 --- a/Source/CPack/cmCPackBundleGenerator.cxx +++ b/Source/CPack/cmCPackBundleGenerator.cxx @@ -2,11 +2,12 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCPackBundleGenerator.h" +#include <sstream> +#include <vector> + #include "cmCPackLog.h" #include "cmSystemTools.h" -#include <cmsys/RegularExpression.hxx> - cmCPackBundleGenerator::cmCPackBundleGenerator() { } diff --git a/Source/CPack/cmCPackBundleGenerator.h b/Source/CPack/cmCPackBundleGenerator.h index 9ea4304..c9200c1 100644 --- a/Source/CPack/cmCPackBundleGenerator.h +++ b/Source/CPack/cmCPackBundleGenerator.h @@ -3,7 +3,11 @@ #ifndef cmCPackBundleGenerator_h #define cmCPackBundleGenerator_h +#include <cmConfigure.h> +#include <string> + #include "cmCPackDragNDropGenerator.h" +#include "cmCPackGenerator.h" /** \class cmCPackBundleGenerator * \brief A generator for OSX bundles diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index bdf4076..fd67df9 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -2,14 +2,16 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCPackDragNDropGenerator.h" +#include "cmCPackGenerator.h" #include "cmCPackLog.h" #include "cmGeneratedFileStream.h" #include "cmSystemTools.h" #include <cmsys/FStream.hxx> #include <cmsys/RegularExpression.hxx> - #include <iomanip> +#include <map> +#include <stdlib.h> #include <CoreFoundation/CoreFoundation.h> diff --git a/Source/CPack/cmCPackDragNDropGenerator.h b/Source/CPack/cmCPackDragNDropGenerator.h index f803ad9..876eab7 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.h +++ b/Source/CPack/cmCPackDragNDropGenerator.h @@ -3,6 +3,12 @@ #ifndef cmCPackDragNDropGenerator_h #define cmCPackDragNDropGenerator_h +#include <cmConfigure.h> +#include <sstream> +#include <stddef.h> +#include <string> +#include <vector> + #include "cmCPackGenerator.h" class cmGeneratedFileStream; diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 09b9c0d..3878a32 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -2,24 +2,24 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCPackGenerator.h" +#include <algorithm> +#include <cmsys/FStream.hxx> +#include <cmsys/Glob.hxx> +#include <cmsys/RegularExpression.hxx> +#include <list> +#include <utility> + #include "cmCPackComponentGroup.h" #include "cmCPackLog.h" #include "cmCryptoHash.h" #include "cmGeneratedFileStream.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" -#include "cmStateTypes.h" +#include "cmStateSnapshot.h" #include "cmXMLSafe.h" #include "cm_auto_ptr.hxx" #include "cmake.h" -#include <algorithm> -#include <cmsys/FStream.hxx> -#include <cmsys/Glob.hxx> -#include <cmsys/RegularExpression.hxx> -#include <list> -#include <utility> - #if defined(__HAIKU__) #include <FindDirectory.h> #include <StorageDefs.h> diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h index f32dd70..b43bf8a 100644 --- a/Source/CPack/cmCPackGenerator.h +++ b/Source/CPack/cmCPackGenerator.h @@ -5,14 +5,15 @@ #include <cmConfigure.h> -#include "cmCPackComponentGroup.h" -#include "cmSystemTools.h" - #include <map> #include <sstream> #include <string> #include <vector> +#include "cmCPackComponentGroup.h" +#include "cmSystemTools.h" + +class cmCPackGenerator; class cmCPackLog; class cmInstalledFile; class cmMakefile; diff --git a/Source/CPack/cmCPackGeneratorFactory.cxx b/Source/CPack/cmCPackGeneratorFactory.cxx index 2a0e65b..b012f01 100644 --- a/Source/CPack/cmCPackGeneratorFactory.cxx +++ b/Source/CPack/cmCPackGeneratorFactory.cxx @@ -2,9 +2,15 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCPackGeneratorFactory.h" +#include <cmConfigure.h> +#include <ostream> +#include <utility> + #include "IFW/cmCPackIFWGenerator.h" +#include "cmAlgorithms.h" #include "cmCPack7zGenerator.h" #include "cmCPackGenerator.h" +#include "cmCPackLog.h" #include "cmCPackNSISGenerator.h" #include "cmCPackSTGZGenerator.h" #include "cmCPackTGZGenerator.h" @@ -36,12 +42,6 @@ #include "WiX/cmCPackWIXGenerator.h" #endif -#include "cmAlgorithms.h" -#include "cmCPackLog.h" - -#include <ostream> -#include <utility> - cmCPackGeneratorFactory::cmCPackGeneratorFactory() { if (cmCPackTGZGenerator::CanGenerate()) { diff --git a/Source/CPack/cmCPackGeneratorFactory.h b/Source/CPack/cmCPackGeneratorFactory.h index 0a98f91..4ee0bc1 100644 --- a/Source/CPack/cmCPackGeneratorFactory.h +++ b/Source/CPack/cmCPackGeneratorFactory.h @@ -3,7 +3,7 @@ #ifndef cmCPackGeneratorFactory_h #define cmCPackGeneratorFactory_h -#include <cmConfigure.h> +#include <cmConfigure.h> // IWYU pragma: keep #include <map> #include <string> diff --git a/Source/CPack/cmCPackLog.cxx b/Source/CPack/cmCPackLog.cxx index 317f613..7d5c192 100644 --- a/Source/CPack/cmCPackLog.cxx +++ b/Source/CPack/cmCPackLog.cxx @@ -2,11 +2,12 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCPackLog.h" +#include <cmConfigure.h> +#include <iostream> + #include "cmGeneratedFileStream.h" #include "cmSystemTools.h" -#include <iostream> - cmCPackLog::cmCPackLog() { this->Verbose = false; diff --git a/Source/CPack/cmCPackLog.h b/Source/CPack/cmCPackLog.h index 9ffe5c4..419c932 100644 --- a/Source/CPack/cmCPackLog.h +++ b/Source/CPack/cmCPackLog.h @@ -3,7 +3,7 @@ #ifndef cmCPackLog_h #define cmCPackLog_h -#include <cmConfigure.h> +#include <cmConfigure.h> // IWYU pragma: keep #include <ostream> #include <string.h> diff --git a/Source/CPack/cmCPackOSXX11Generator.cxx b/Source/CPack/cmCPackOSXX11Generator.cxx index 225c1fb..0d8dc48 100644 --- a/Source/CPack/cmCPackOSXX11Generator.cxx +++ b/Source/CPack/cmCPackOSXX11Generator.cxx @@ -2,16 +2,13 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCPackOSXX11Generator.h" +#include <sstream> +#include <sys/stat.h> + +#include "cmCPackGenerator.h" #include "cmCPackLog.h" #include "cmGeneratedFileStream.h" -#include "cmGlobalGenerator.h" -#include "cmMakefile.h" #include "cmSystemTools.h" -#include "cmake.h" - -#include <cmsys/Glob.hxx> -#include <cmsys/SystemTools.hxx> -#include <sys/stat.h> cmCPackOSXX11Generator::cmCPackOSXX11Generator() { diff --git a/Source/CPack/cmCPackOSXX11Generator.h b/Source/CPack/cmCPackOSXX11Generator.h index eb1e5ff..1918e21 100644 --- a/Source/CPack/cmCPackOSXX11Generator.h +++ b/Source/CPack/cmCPackOSXX11Generator.h @@ -3,6 +3,9 @@ #ifndef cmCPackOSXX11Generator_h #define cmCPackOSXX11Generator_h +#include <cmConfigure.h> +#include <string> + #include "cmCPackGenerator.h" /** \class cmCPackOSXX11Generator diff --git a/Source/CPack/cmCPackPKGGenerator.cxx b/Source/CPack/cmCPackPKGGenerator.cxx index 785ee01..70ae267 100644 --- a/Source/CPack/cmCPackPKGGenerator.cxx +++ b/Source/CPack/cmCPackPKGGenerator.cxx @@ -2,18 +2,13 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCPackPKGGenerator.h" +#include <vector> + #include "cmCPackComponentGroup.h" +#include "cmCPackGenerator.h" #include "cmCPackLog.h" -#include "cmGeneratedFileStream.h" -#include "cmGlobalGenerator.h" -#include "cmLocalGenerator.h" -#include "cmMakefile.h" #include "cmSystemTools.h" #include "cmXMLWriter.h" -#include "cmake.h" - -#include <cmsys/Glob.hxx> -#include <cmsys/SystemTools.hxx> cmCPackPKGGenerator::cmCPackPKGGenerator() { diff --git a/Source/CPack/cmCPackPKGGenerator.h b/Source/CPack/cmCPackPKGGenerator.h index bb3c1a7..1e96a62 100644 --- a/Source/CPack/cmCPackPKGGenerator.h +++ b/Source/CPack/cmCPackPKGGenerator.h @@ -5,10 +5,12 @@ #include <cmConfigure.h> #include <set> +#include <sstream> +#include <string> +#include "cmCPackComponentGroup.h" #include "cmCPackGenerator.h" -class cmCPackComponent; class cmXMLWriter; /** \class cmCPackPKGGenerator diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx index 25e8a1c..8000d6e 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.cxx +++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx @@ -2,20 +2,20 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCPackPackageMakerGenerator.h" +#include <assert.h> +#include <cmsys/FStream.hxx> +#include <cmsys/RegularExpression.hxx> +#include <map> +#include <sstream> +#include <stdio.h> +#include <stdlib.h> +#include <string> + #include "cmCPackComponentGroup.h" #include "cmCPackLog.h" #include "cmGeneratedFileStream.h" -#include "cmGlobalGenerator.h" -#include "cmMakefile.h" #include "cmSystemTools.h" #include "cmXMLWriter.h" -#include "cmake.h" - -#include <cmsys/FStream.hxx> -#include <cmsys/Glob.hxx> -#include <cmsys/SystemTools.hxx> - -#include <assert.h> static inline unsigned int getVersion(unsigned int major, unsigned int minor) { diff --git a/Source/CPack/cmCPackPackageMakerGenerator.h b/Source/CPack/cmCPackPackageMakerGenerator.h index d679bc1..d4c6744 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.h +++ b/Source/CPack/cmCPackPackageMakerGenerator.h @@ -3,6 +3,9 @@ #ifndef cmCPackPackageMakerGenerator_h #define cmCPackPackageMakerGenerator_h +#include <cmConfigure.h> + +#include "cmCPackGenerator.h" #include "cmCPackPKGGenerator.h" class cmCPackComponent; diff --git a/Source/CPack/cmCPackProductBuildGenerator.cxx b/Source/CPack/cmCPackProductBuildGenerator.cxx index ff0ec79..a46e3a6 100644 --- a/Source/CPack/cmCPackProductBuildGenerator.cxx +++ b/Source/CPack/cmCPackProductBuildGenerator.cxx @@ -2,17 +2,14 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCPackProductBuildGenerator.h" +#include <map> +#include <sstream> +#include <stddef.h> + #include "cmCPackComponentGroup.h" #include "cmCPackLog.h" #include "cmGeneratedFileStream.h" -#include "cmGlobalGenerator.h" -#include "cmLocalGenerator.h" -#include "cmMakefile.h" #include "cmSystemTools.h" -#include "cmake.h" - -#include <cmsys/Glob.hxx> -#include <cmsys/SystemTools.hxx> cmCPackProductBuildGenerator::cmCPackProductBuildGenerator() { diff --git a/Source/CPack/cmCPackProductBuildGenerator.h b/Source/CPack/cmCPackProductBuildGenerator.h index 4145eb4..b6da470 100644 --- a/Source/CPack/cmCPackProductBuildGenerator.h +++ b/Source/CPack/cmCPackProductBuildGenerator.h @@ -3,6 +3,10 @@ #ifndef cmCPackProductBuildGenerator_h #define cmCPackProductBuildGenerator_h +#include <cmConfigure.h> +#include <string> + +#include "cmCPackGenerator.h" #include "cmCPackPKGGenerator.h" class cmCPackComponent; diff --git a/Source/CPack/cmCPackRPMGenerator.cxx b/Source/CPack/cmCPackRPMGenerator.cxx index 9817327..8ec03c2 100644 --- a/Source/CPack/cmCPackRPMGenerator.cxx +++ b/Source/CPack/cmCPackRPMGenerator.cxx @@ -2,17 +2,18 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCPackRPMGenerator.h" -#include "cmCPackComponentGroup.h" -#include "cmCPackGenerator.h" -#include "cmCPackLog.h" -#include "cmSystemTools.h" - #include <algorithm> +#include <ctype.h> #include <map> #include <ostream> #include <utility> #include <vector> +#include "cmCPackComponentGroup.h" +#include "cmCPackGenerator.h" +#include "cmCPackLog.h" +#include "cmSystemTools.h" + cmCPackRPMGenerator::cmCPackRPMGenerator() { } diff --git a/Source/CPack/cmCPackSTGZGenerator.cxx b/Source/CPack/cmCPackSTGZGenerator.cxx index 66ba9f6..682394e 100644 --- a/Source/CPack/cmCPackSTGZGenerator.cxx +++ b/Source/CPack/cmCPackSTGZGenerator.cxx @@ -2,10 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCPackSTGZGenerator.h" -#include "cmCPackGenerator.h" -#include "cmCPackLog.h" -#include "cmSystemTools.h" - #include <cmsys/FStream.hxx> #include <sstream> #include <stdio.h> @@ -16,6 +12,10 @@ // include sys/stat.h after sys/types.h #include <sys/stat.h> +#include "cmCPackGenerator.h" +#include "cmCPackLog.h" +#include "cmSystemTools.h" + cmCPackSTGZGenerator::cmCPackSTGZGenerator() { } diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index 06472c6..fa526ae 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -2,6 +2,20 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include <cmConfigure.h> +#include <cmsys/CommandLineArguments.hxx> +#include <cmsys/Encoding.hxx> +#include <iostream> +#include <map> +#include <sstream> +#include <stddef.h> +#include <string> +#include <utility> +#include <vector> + +#if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE) +#include <cmsys/ConsoleBuf.hxx> +#endif + #include "cmCPackGenerator.h" #include "cmCPackGeneratorFactory.h" #include "cmCPackLog.h" @@ -10,24 +24,11 @@ #include "cmGlobalGenerator.h" #include "cmMakefile.h" #include "cmState.h" -#include "cmStateTypes.h" +#include "cmStateSnapshot.h" #include "cmSystemTools.h" #include "cm_auto_ptr.hxx" #include "cmake.h" -#include <cmsys/CommandLineArguments.hxx> -#include <cmsys/Encoding.hxx> -#if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE) -#include <cmsys/ConsoleBuf.hxx> -#endif -#include <iostream> -#include <map> -#include <sstream> -#include <stddef.h> -#include <string> -#include <utility> -#include <vector> - static const char* cmDocumentationName[][2] = { { CM_NULLPTR, " cpack - Packaging driver provided by CMake." }, { CM_NULLPTR, CM_NULLPTR } diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index 7b4d994..a455908 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -7,6 +7,7 @@ #include "cmFileTimeComparison.h" #include "cmGeneratedFileStream.h" #include "cmMakefile.h" +#include "cmProcessOutput.h" #include "cmSystemTools.h" #include "cmXMLWriter.h" @@ -765,7 +766,7 @@ void cmCTestBuildHandler::LaunchHelper::WriteScrapeMatchers( int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal, const char* dir, int timeout, - std::ostream& ofs) + std::ostream& ofs, Encoding encoding) { // First generate the command and arguments std::vector<std::string> args = cmSystemTools::ParseArguments(command); @@ -809,6 +810,8 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal, char* data; int length; + cmProcessOutput processOutput(encoding); + std::string strdata; cmCTestOptionalLog( this->CTest, HANDLER_PROGRESS_OUTPUT, " Each symbol represents " << tick_len << " bytes of output." << std::endl @@ -842,13 +845,25 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal, // Process the chunk of data if (res == cmsysProcess_Pipe_STDERR) { - this->ProcessBuffer(data, length, tick, tick_len, ofs, + processOutput.DecodeText(data, length, strdata, 1); + this->ProcessBuffer(strdata.c_str(), strdata.size(), tick, tick_len, ofs, &this->BuildProcessingErrorQueue); } else { - this->ProcessBuffer(data, length, tick, tick_len, ofs, + processOutput.DecodeText(data, length, strdata, 2); + this->ProcessBuffer(strdata.c_str(), strdata.size(), tick, tick_len, ofs, &this->BuildProcessingQueue); } } + processOutput.DecodeText(std::string(), strdata, 1); + if (!strdata.empty()) { + this->ProcessBuffer(strdata.c_str(), strdata.size(), tick, tick_len, ofs, + &this->BuildProcessingErrorQueue); + } + processOutput.DecodeText(std::string(), strdata, 2); + if (!strdata.empty()) { + this->ProcessBuffer(strdata.c_str(), strdata.size(), tick, tick_len, ofs, + &this->BuildProcessingQueue); + } this->ProcessBuffer(CM_NULLPTR, 0, tick, tick_len, ofs, &this->BuildProcessingQueue); @@ -920,7 +935,7 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal, //###################################################################### //###################################################################### -void cmCTestBuildHandler::ProcessBuffer(const char* data, int length, +void cmCTestBuildHandler::ProcessBuffer(const char* data, size_t length, size_t& tick, size_t tick_len, std::ostream& ofs, t_BuildProcessingQueueType* queue) diff --git a/Source/CTest/cmCTestBuildHandler.h b/Source/CTest/cmCTestBuildHandler.h index 5bd1157..a2f6112 100644 --- a/Source/CTest/cmCTestBuildHandler.h +++ b/Source/CTest/cmCTestBuildHandler.h @@ -7,6 +7,7 @@ #include "cmCTestGenericHandler.h" +#include <cmProcessOutput.h> #include <cmsys/RegularExpression.hxx> #include <deque> #include <iosfwd> @@ -25,6 +26,7 @@ class cmCTestBuildHandler : public cmCTestGenericHandler { public: typedef cmCTestGenericHandler Superclass; + typedef cmProcessOutput::Encoding Encoding; /* * The main entry point for this class @@ -49,7 +51,8 @@ private: //! Run command specialized for make and configure. Returns process status // and retVal is return value or exception. int RunMakeCommand(const char* command, int* retVal, const char* dir, - int timeout, std::ostream& ofs); + int timeout, std::ostream& ofs, + Encoding encoding = cmProcessOutput::Auto); enum { @@ -107,7 +110,7 @@ private: typedef std::deque<char> t_BuildProcessingQueueType; - void ProcessBuffer(const char* data, int length, size_t& tick, + void ProcessBuffer(const char* data, size_t length, size_t& tick, size_t tick_len, std::ostream& ofs, t_BuildProcessingQueueType* queue); int ProcessSingleLine(const char* data); diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index 1bc1851..d30f6b3 100644 --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@ -2,12 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestGIT.h" -#include "cmAlgorithms.h" -#include "cmCTest.h" -#include "cmCTestVC.h" -#include "cmProcessTools.h" -#include "cmSystemTools.h" - #include <cmsys/FStream.hxx> #include <cmsys/Process.h> #include <ctype.h> @@ -16,6 +10,13 @@ #include <time.h> #include <vector> +#include "cmAlgorithms.h" +#include "cmCTest.h" +#include "cmCTestVC.h" +#include "cmProcessOutput.h" +#include "cmProcessTools.h" +#include "cmSystemTools.h" + static unsigned int cmCTestGITVersion(unsigned int epic, unsigned int major, unsigned int minor, unsigned int fix) { @@ -91,7 +92,8 @@ std::string cmCTestGIT::FindGitDir() std::string git_dir_line; OneLineParser rev_parse_out(this, "rev-parse-out> ", git_dir_line); OutputLogger rev_parse_err(this->Log, "rev-parse-err> "); - if (this->RunChild(git_rev_parse, &rev_parse_out, &rev_parse_err)) { + if (this->RunChild(git_rev_parse, &rev_parse_out, &rev_parse_err, CM_NULLPTR, + cmProcessOutput::UTF8)) { git_dir = git_dir_line; } if (git_dir.empty()) { @@ -114,7 +116,8 @@ std::string cmCTestGIT::FindGitDir() 0 }; OneLineParser cygpath_out(this, "cygpath-out> ", git_dir_line); OutputLogger cygpath_err(this->Log, "cygpath-err> "); - if (this->RunChild(cygpath, &cygpath_out, &cygpath_err)) { + if (this->RunChild(cygpath, &cygpath_out, &cygpath_err, CM_NULLPTR, + cmProcessOutput::UTF8)) { git_dir = git_dir_line; } } @@ -134,7 +137,8 @@ std::string cmCTestGIT::FindTopDir() std::string cdup; OneLineParser rev_parse_out(this, "rev-parse-out> ", cdup); OutputLogger rev_parse_err(this->Log, "rev-parse-err> "); - if (this->RunChild(git_rev_parse, &rev_parse_out, &rev_parse_err) && + if (this->RunChild(git_rev_parse, &rev_parse_out, &rev_parse_err, CM_NULLPTR, + cmProcessOutput::UTF8) && !cdup.empty()) { top_dir += "/"; top_dir += cdup; @@ -624,7 +628,7 @@ void cmCTestGIT::LoadRevisions() CommitParser out(this, "dt-out> "); OutputLogger err(this->Log, "dt-err> "); - this->RunProcess(cp, &out, &err); + this->RunProcess(cp, &out, &err, cmProcessOutput::UTF8); // Send one extra zero-byte to terminate the last record. out.Process("", 1); @@ -641,14 +645,16 @@ void cmCTestGIT::LoadModifications() CM_NULLPTR }; OutputLogger ui_out(this->Log, "ui-out> "); OutputLogger ui_err(this->Log, "ui-err> "); - this->RunChild(git_update_index, &ui_out, &ui_err); + this->RunChild(git_update_index, &ui_out, &ui_err, CM_NULLPTR, + cmProcessOutput::UTF8); // Use 'git diff-index' to get modified files. const char* git_diff_index[] = { git, "diff-index", "-z", "HEAD", "--", CM_NULLPTR }; DiffParser out(this, "di-out> "); OutputLogger err(this->Log, "di-err> "); - this->RunChild(git_diff_index, &out, &err); + this->RunChild(git_diff_index, &out, &err, CM_NULLPTR, + cmProcessOutput::UTF8); for (std::vector<Change>::const_iterator ci = out.Changes.begin(); ci != out.Changes.end(); ++ci) { diff --git a/Source/CTest/cmCTestGenericHandler.cxx b/Source/CTest/cmCTestGenericHandler.cxx index c093cc6..7638f45 100644 --- a/Source/CTest/cmCTestGenericHandler.cxx +++ b/Source/CTest/cmCTestGenericHandler.cxx @@ -2,12 +2,13 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestGenericHandler.h" -#include "cmCTest.h" -#include "cmSystemTools.h" - +#include <cmConfigure.h> #include <sstream> #include <utility> +#include "cmCTest.h" +#include "cmSystemTools.h" + cmCTestGenericHandler::cmCTestGenericHandler() { this->HandlerVerbose = cmSystemTools::OUTPUT_NONE; diff --git a/Source/CTest/cmCTestGenericHandler.h b/Source/CTest/cmCTestGenericHandler.h index 4176eb2..2ebbe70 100644 --- a/Source/CTest/cmCTestGenericHandler.h +++ b/Source/CTest/cmCTestGenericHandler.h @@ -3,16 +3,16 @@ #ifndef cmCTestGenericHandler_h #define cmCTestGenericHandler_h -#include <cmConfigure.h> - -#include "cmCTest.h" -#include "cmSystemTools.h" +#include <cmConfigure.h> // IWYU pragma: keep #include <map> #include <stddef.h> #include <string> #include <vector> +#include "cmCTest.h" +#include "cmSystemTools.h" + class cmCTestCommand; class cmGeneratedFileStream; class cmMakefile; diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index f7a6e0b..03e0319 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -4,23 +4,24 @@ #include <cmConfigure.h> +#include <cmsys/FStream.hxx> +#include <cmsys/Process.h> +#include <cmsys/RegularExpression.hxx> +#include <iostream> +#include <stdlib.h> +#include <string.h> + #include "cmCryptoHash.h" #include "cmGeneratedFileStream.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" -#include "cmStateTypes.h" +#include "cmProcessOutput.h" +#include "cmStateSnapshot.h" #include "cmSystemTools.h" #include "cmXMLWriter.h" +#include "cm_auto_ptr.hxx" #include "cmake.h" -#include <cm_auto_ptr.hxx> -#include <cmsys/FStream.hxx> -#include <cmsys/Process.h> -#include <cmsys/RegularExpression.hxx> -#include <iostream> -#include <stdlib.h> -#include <string.h> - #ifdef _WIN32 #include <fcntl.h> // for _O_BINARY #include <io.h> // for _setmode @@ -225,17 +226,31 @@ void cmCTestLaunch::RunChild() if (!this->Passthru) { char* data = CM_NULLPTR; int length = 0; + cmProcessOutput processOutput; + std::string strdata; while (int p = cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR)) { if (p == cmsysProcess_Pipe_STDOUT) { - fout.write(data, length); - std::cout.write(data, length); + processOutput.DecodeText(data, length, strdata, 1); + fout.write(strdata.c_str(), strdata.size()); + std::cout.write(strdata.c_str(), strdata.size()); this->HaveOut = true; } else if (p == cmsysProcess_Pipe_STDERR) { - ferr.write(data, length); - std::cerr.write(data, length); + processOutput.DecodeText(data, length, strdata, 2); + ferr.write(strdata.c_str(), strdata.size()); + std::cerr.write(strdata.c_str(), strdata.size()); this->HaveErr = true; } } + processOutput.DecodeText(std::string(), strdata, 1); + if (!strdata.empty()) { + fout.write(strdata.c_str(), strdata.size()); + std::cout.write(strdata.c_str(), strdata.size()); + } + processOutput.DecodeText(std::string(), strdata, 2); + if (!strdata.empty()) { + ferr.write(strdata.c_str(), strdata.size()); + std::cerr.write(strdata.c_str(), strdata.size()); + } } // Wait for the real command to finish. diff --git a/Source/CTest/cmCTestMemCheckCommand.cxx b/Source/CTest/cmCTestMemCheckCommand.cxx index 5e4c5ae..fd7c3a9 100644 --- a/Source/CTest/cmCTestMemCheckCommand.cxx +++ b/Source/CTest/cmCTestMemCheckCommand.cxx @@ -2,6 +2,9 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestMemCheckCommand.h" +#include <sstream> +#include <vector> + #include "cmCTest.h" #include "cmCTestGenericHandler.h" #include "cmCTestMemCheckHandler.h" diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index 0f27fac..2c31f60 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -329,10 +329,8 @@ void cmCTestMemCheckHandler::GenerateDartOutput(cmXMLWriter& xml) } xml.EndElement(); // TestList cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, - "-- Processing memory checking output: ", this->Quiet); + "-- Processing memory checking output:\n", this->Quiet); size_t total = this->TestResults.size(); - size_t step = total / 10; - size_t current = 0; for (cc = 0; cc < this->TestResults.size(); cc++) { cmCTestTestResult* result = &this->TestResults[cc]; std::string memcheckstr; @@ -347,18 +345,29 @@ void cmCTestMemCheckHandler::GenerateDartOutput(cmXMLWriter& xml) static_cast<size_t>(this->CustomMaximumFailedTestOutputSize)); this->WriteTestResultHeader(xml, result); xml.StartElement("Results"); + int memoryErrors = 0; for (std::vector<int>::size_type kk = 0; kk < memcheckresults.size(); ++kk) { if (memcheckresults[kk]) { xml.StartElement("Defect"); xml.Attribute("type", this->ResultStringsLong[kk]); xml.Content(memcheckresults[kk]); + memoryErrors += memcheckresults[kk]; xml.EndElement(); // Defect } this->GlobalResults[kk] += memcheckresults[kk]; } xml.EndElement(); // Results - + if (memoryErrors > 0) { + const int maxTestNameWidth = this->CTest->GetMaxTestNameWidth(); + std::string outname = result->Name + " "; + outname.resize(maxTestNameWidth + 4, '.'); + cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, cc + 1 + << "/" << total << " MemCheck: #" + << result->TestCount << ": " << outname + << " Defects: " << memoryErrors << std::endl, + this->Quiet); + } xml.StartElement("Log"); if (this->CTest->ShouldCompressTestOutput()) { this->CTest->CompressString(memcheckstr); @@ -369,13 +378,16 @@ void cmCTestMemCheckHandler::GenerateDartOutput(cmXMLWriter& xml) xml.EndElement(); // Log this->WriteTestResultFooter(xml, result); - if (current < cc) { - cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "#" << std::flush, - this->Quiet); - current += step; - } } - cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, std::endl, this->Quiet); + cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, + "MemCheck log files can be found here: " + "( * corresponds to test number)" + << std::endl, + this->Quiet); + std::string output = this->MemoryTesterOutputFile; + cmSystemTools::ReplaceString(output, "??", "*"); + cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, output << std::endl, + this->Quiet); cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "Memory checking results:" << std::endl, this->Quiet); xml.StartElement("DefectList"); diff --git a/Source/CTest/cmCTestRunTest.h b/Source/CTest/cmCTestRunTest.h index a10e271..ee4630a 100644 --- a/Source/CTest/cmCTestRunTest.h +++ b/Source/CTest/cmCTestRunTest.h @@ -5,11 +5,13 @@ #include <cmConfigure.h> // IWYU pragma: keep -#include <cmCTestTestHandler.h> +#include <set> #include <stddef.h> #include <string> #include <vector> +#include "cmCTestTestHandler.h" + class cmCTest; class cmProcess; diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 08ea4ee..b537242 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -2,6 +2,15 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestScriptHandler.h" +#include <cmsys/Directory.hxx> +#include <cmsys/Process.h> +#include <map> +#include <sstream> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <utility> + #include "cmCTest.h" #include "cmCTestBuildCommand.h" #include "cmCTestCommand.h" @@ -23,19 +32,10 @@ #include "cmMakefile.h" #include "cmState.h" #include "cmStateDirectory.h" -#include "cmStateTypes.h" +#include "cmStateSnapshot.h" #include "cmSystemTools.h" #include "cmake.h" -#include <cmsys/Directory.hxx> -#include <cmsys/Process.h> -#include <map> -#include <sstream> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <utility> - #ifdef _WIN32 #include <windows.h> #else diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 8383132..0f13c1e 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -2,25 +2,26 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestSubmitHandler.h" +#include <cm_curl.h> +#include <cm_jsoncpp_reader.h> +#include <cm_jsoncpp_value.h> +#include <cmsys/Process.h> +#include <sstream> +#include <stdio.h> +#include <stdlib.h> + #include "cmCTest.h" #include "cmCTestCurl.h" #include "cmCTestScriptHandler.h" #include "cmCurl.h" #include "cmGeneratedFileStream.h" +#include "cmProcessOutput.h" #include "cmState.h" -#include "cmStateTypes.h" #include "cmSystemTools.h" +#include "cmThirdParty.h" #include "cmXMLParser.h" #include "cmake.h" -#include <cm_curl.h> -#include <cm_jsoncpp_reader.h> -#include <cm_jsoncpp_value.h> -#include <cmsys/Process.h> -#include <sstream> -#include <stdio.h> -#include <stdlib.h> - #if defined(CTEST_USE_XMLRPC) #include "cmVersion.h" #include <cm_xmlrpc.h> @@ -784,10 +785,20 @@ bool cmCTestSubmitHandler::SubmitUsingSCP(const std::string& scp_command, cmsysProcess_Execute(cp); char* data; int length; + cmProcessOutput processOutput; + std::string strdata; while (cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR)) { + processOutput.DecodeText(data, length, strdata); cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, - cmCTestLogWrite(data, length), this->Quiet); + cmCTestLogWrite(strdata.c_str(), strdata.size()), + this->Quiet); + } + processOutput.DecodeText(std::string(), strdata); + if (!strdata.empty()) { + cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + cmCTestLogWrite(strdata.c_str(), strdata.size()), + this->Quiet); } cmsysProcess_WaitForExit(cp, CM_NULLPTR); diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 132d049..ab43dbc 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -2,21 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestTestHandler.h" -#include "cmCTest.h" -#include "cmCTestBatchTestHandler.h" -#include "cmCTestMultiProcessHandler.h" -#include "cmCommand.h" -#include "cmGeneratedFileStream.h" -#include "cmGlobalGenerator.h" -#include "cmMakefile.h" -#include "cmState.h" -#include "cmStateTypes.h" -#include "cmSystemTools.h" -#include "cmXMLWriter.h" -#include "cm_auto_ptr.hxx" -#include "cm_utf8.h" -#include "cmake.h" - #include <algorithm> #include <cmsys/Base64.h> #include <cmsys/Directory.hxx> @@ -32,6 +17,21 @@ #include <string.h> #include <time.h> +#include "cmCTest.h" +#include "cmCTestBatchTestHandler.h" +#include "cmCTestMultiProcessHandler.h" +#include "cmCommand.h" +#include "cmGeneratedFileStream.h" +#include "cmGlobalGenerator.h" +#include "cmMakefile.h" +#include "cmState.h" +#include "cmStateSnapshot.h" +#include "cmSystemTools.h" +#include "cmXMLWriter.h" +#include "cm_auto_ptr.hxx" +#include "cm_utf8.h" +#include "cmake.h" + class cmExecutionStatus; class cmCTestSubdirCommand : public cmCommand diff --git a/Source/CTest/cmCTestUploadCommand.cxx b/Source/CTest/cmCTestUploadCommand.cxx index 9266bce..717117a 100644 --- a/Source/CTest/cmCTestUploadCommand.cxx +++ b/Source/CTest/cmCTestUploadCommand.cxx @@ -2,6 +2,9 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestUploadCommand.h" +#include <sstream> +#include <vector> + #include "cmCTest.h" #include "cmCTestGenericHandler.h" #include "cmCTestUploadHandler.h" @@ -9,8 +12,6 @@ #include "cmSystemTools.h" #include "cmake.h" -#include <sstream> - cmCTestGenericHandler* cmCTestUploadCommand::InitializeHandler() { cmCTestGenericHandler* handler = diff --git a/Source/CTest/cmCTestVC.cxx b/Source/CTest/cmCTestVC.cxx index 7a2fa69..444c43d 100644 --- a/Source/CTest/cmCTestVC.cxx +++ b/Source/CTest/cmCTestVC.cxx @@ -76,7 +76,8 @@ bool cmCTestVC::InitialCheckout(const char* command) } bool cmCTestVC::RunChild(char const* const* cmd, OutputParser* out, - OutputParser* err, const char* workDir) + OutputParser* err, const char* workDir, + Encoding encoding) { this->Log << this->ComputeCommandLine(cmd) << "\n"; @@ -84,7 +85,7 @@ bool cmCTestVC::RunChild(char const* const* cmd, OutputParser* out, cmsysProcess_SetCommand(cp, cmd); workDir = workDir ? workDir : this->SourceDirectory.c_str(); cmsysProcess_SetWorkingDirectory(cp, workDir); - this->RunProcess(cp, out, err); + this->RunProcess(cp, out, err, encoding); int result = cmsysProcess_GetExitValue(cp); cmsysProcess_Delete(cp); return result == 0; @@ -102,7 +103,7 @@ std::string cmCTestVC::ComputeCommandLine(char const* const* cmd) } bool cmCTestVC::RunUpdateCommand(char const* const* cmd, OutputParser* out, - OutputParser* err) + OutputParser* err, Encoding encoding) { // Report the command line. this->UpdateCommandLine = this->ComputeCommandLine(cmd); @@ -112,7 +113,7 @@ bool cmCTestVC::RunUpdateCommand(char const* const* cmd, OutputParser* out, } // Run the command. - return this->RunChild(cmd, out, err); + return this->RunChild(cmd, out, err, CM_NULLPTR, encoding); } std::string cmCTestVC::GetNightlyTime() diff --git a/Source/CTest/cmCTestVC.h b/Source/CTest/cmCTestVC.h index 4f2bba0..2681ba0 100644 --- a/Source/CTest/cmCTestVC.h +++ b/Source/CTest/cmCTestVC.h @@ -5,11 +5,12 @@ #include <cmConfigure.h> -#include "cmProcessTools.h" - #include <iosfwd> #include <string> +#include "cmProcessOutput.h" +#include "cmProcessTools.h" + class cmCTest; class cmXMLWriter; @@ -116,11 +117,13 @@ protected: /** Run a command line and send output to given parsers. */ bool RunChild(char const* const* cmd, OutputParser* out, OutputParser* err, - const char* workDir = CM_NULLPTR); + const char* workDir = CM_NULLPTR, + Encoding encoding = cmProcessOutput::Auto); /** Run VC update command line and send output to given parsers. */ bool RunUpdateCommand(char const* const* cmd, OutputParser* out, - OutputParser* err = CM_NULLPTR); + OutputParser* err = CM_NULLPTR, + Encoding encoding = cmProcessOutput::Auto); /** Write xml element for one file. */ void WriteXMLEntry(cmXMLWriter& xml, std::string const& path, diff --git a/Source/CTest/cmProcess.cxx b/Source/CTest/cmProcess.cxx index a24fe21..98bd3bb 100644 --- a/Source/CTest/cmProcess.cxx +++ b/Source/CTest/cmProcess.cxx @@ -3,6 +3,7 @@ #include "cmProcess.h" #include <cmConfigure.h> +#include <cmProcessOutput.h> #include <cmSystemTools.h> #include <iostream> @@ -104,6 +105,8 @@ bool cmProcess::Buffer::GetLast(std::string& line) int cmProcess::GetNextOutputLine(std::string& line, double timeout) { + cmProcessOutput processOutput; + std::string strdata; for (;;) { // Look for lines already buffered. if (this->Output.GetLine(line)) { @@ -118,12 +121,17 @@ int cmProcess::GetNextOutputLine(std::string& line, double timeout) return cmsysProcess_Pipe_Timeout; } if (p == cmsysProcess_Pipe_STDOUT) { - this->Output.insert(this->Output.end(), data, data + length); + processOutput.DecodeText(data, length, strdata); + this->Output.insert(this->Output.end(), strdata.begin(), strdata.end()); } else { // p == cmsysProcess_Pipe_None // The process will provide no more data. break; } } + processOutput.DecodeText(std::string(), strdata); + if (!strdata.empty()) { + this->Output.insert(this->Output.end(), strdata.begin(), strdata.end()); + } // Look for partial last lines. if (this->Output.GetLast(line)) { diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index ebd35f3..4b5b4b1 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -347,61 +347,56 @@ void cmCursesMainForm::PrintKeys(int process /* = 0 */) cw = reinterpret_cast<cmCursesWidget*>(field_userptr(currentField)); } - if (cw) { - cw->PrintKeys(); - } - - // { - // } - // else - // { - char firstLine[512] = ""; - char secondLine[512] = ""; - char thirdLine[512] = ""; - if (process) { - const char* clearLine = - " "; - strcpy(firstLine, clearLine); - strcpy(secondLine, clearLine); - strcpy(thirdLine, clearLine); - } else { - if (this->OkToGenerate) { - sprintf(firstLine, - "Press [c] to configure Press [g] to generate and exit"); + char fmt_s[] = "%s"; + if (cw == CM_NULLPTR || !cw->PrintKeys()) { + char firstLine[512] = ""; + char secondLine[512] = ""; + char thirdLine[512] = ""; + if (process) { + const char* clearLine = + " "; + strcpy(firstLine, clearLine); + strcpy(secondLine, clearLine); + strcpy(thirdLine, clearLine); } else { - sprintf(firstLine, - "Press [c] to configure "); - } - { - const char* toggleKeyInstruction = - "Press [t] to toggle advanced mode (Currently %s)"; - sprintf(thirdLine, toggleKeyInstruction, - this->AdvancedMode ? "On" : "Off"); + if (this->OkToGenerate) { + sprintf(firstLine, + "Press [c] to configure Press [g] to generate and exit"); + } else { + sprintf(firstLine, + "Press [c] to configure "); + } + { + const char* toggleKeyInstruction = + "Press [t] to toggle advanced mode (Currently %s)"; + sprintf(thirdLine, toggleKeyInstruction, + this->AdvancedMode ? "On" : "Off"); + } + sprintf(secondLine, "Press [h] for help " + "Press [q] to quit without generating"); } - sprintf(secondLine, "Press [h] for help " - "Press [q] to quit without generating"); - } - curses_move(y - 4, 0); - char fmt_s[] = "%s"; - char fmt[512] = "Press [enter] to edit option Press [d] to delete an entry"; - if (process) { - strcpy(fmt, " "); + curses_move(y - 4, 0); + char fmt[512] = + "Press [enter] to edit option Press [d] to delete an entry"; + if (process) { + strcpy(fmt, " "); + } + printw(fmt_s, fmt); + curses_move(y - 3, 0); + printw(fmt_s, firstLine); + curses_move(y - 2, 0); + printw(fmt_s, secondLine); + curses_move(y - 1, 0); + printw(fmt_s, thirdLine); } - printw(fmt_s, fmt); - curses_move(y - 3, 0); - printw(fmt_s, firstLine); - curses_move(y - 2, 0); - printw(fmt_s, secondLine); - curses_move(y - 1, 0); - printw(fmt_s, thirdLine); if (cw) { - sprintf(firstLine, "Page %d of %d", cw->GetPage(), this->NumberOfPages); - curses_move(0, 65 - static_cast<unsigned int>(strlen(firstLine)) - 1); - printw(fmt_s, firstLine); + char pageLine[512] = ""; + sprintf(pageLine, "Page %d of %d", cw->GetPage(), this->NumberOfPages); + curses_move(0, 65 - static_cast<unsigned int>(strlen(pageLine)) - 1); + printw(fmt_s, pageLine); } - // } pos_form_cursor(this->Form); } diff --git a/Source/CursesDialog/cmCursesStringWidget.cxx b/Source/CursesDialog/cmCursesStringWidget.cxx index eabc642..ff189f0 100644 --- a/Source/CursesDialog/cmCursesStringWidget.cxx +++ b/Source/CursesDialog/cmCursesStringWidget.cxx @@ -202,7 +202,9 @@ bool cmCursesStringWidget::PrintKeys() printw(fmt_s, firstLine); curses_move(y - 3, 0); - printw(fmt_s, "Editing option, press [enter] to leave edit."); + printw(fmt_s, "Editing option, press [enter] to confirm"); + curses_move(y - 2, 0); + printw(fmt_s, " press [esc] to cancel"); return true; } return false; diff --git a/Source/bindexplib.cxx b/Source/bindexplib.cxx index db97c47..eded883 100644 --- a/Source/bindexplib.cxx +++ b/Source/bindexplib.cxx @@ -62,11 +62,10 @@ *---------------------------------------------------------------------- */ #include "bindexplib.h" + #include <cmsys/Encoding.hxx> #include <fstream> #include <iostream> -#include <stdio.h> -#include <string> #include <windows.h> typedef struct cmANON_OBJECT_HEADER_BIGOBJ { diff --git a/Source/bindexplib.h b/Source/bindexplib.h index 1a0c3a3..d6900ba 100644 --- a/Source/bindexplib.h +++ b/Source/bindexplib.h @@ -5,8 +5,9 @@ #include <cmConfigure.h> -#include "cmStandardIncludes.h" - +#include <set> +#include <stdio.h> +#include <string> class bindexplib { diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index f35a0b3..1527b30 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -41,6 +41,7 @@ #include "cmGeneratedFileStream.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" +#include "cmProcessOutput.h" #include "cmState.h" #include "cmStateSnapshot.h" #include "cmStateTypes.h" @@ -960,7 +961,7 @@ int cmCTest::GetTestModelFromString(const char* str) int cmCTest::RunMakeCommand(const char* command, std::string& output, int* retVal, const char* dir, int timeout, - std::ostream& ofs) + std::ostream& ofs, Encoding encoding) { // First generate the command and arguments std::vector<std::string> args = cmSystemTools::ParseArguments(command); @@ -999,16 +1000,19 @@ int cmCTest::RunMakeCommand(const char* command, std::string& output, char* data; int length; + cmProcessOutput processOutput(encoding); + std::string strdata; cmCTestLog(this, HANDLER_PROGRESS_OUTPUT, " Each . represents " << tick_len << " bytes of output" << std::endl << " " << std::flush); while (cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR)) { - for (int cc = 0; cc < length; ++cc) { - if (data[cc] == 0) { - data[cc] = '\n'; + processOutput.DecodeText(data, length, strdata); + for (size_t cc = 0; cc < strdata.size(); ++cc) { + if (strdata[cc] == 0) { + strdata[cc] = '\n'; } } - output.append(data, length); + output.append(strdata); while (output.size() > (tick * tick_len)) { tick++; cmCTestLog(this, HANDLER_PROGRESS_OUTPUT, "." << std::flush); @@ -1019,9 +1023,19 @@ int cmCTest::RunMakeCommand(const char* command, std::string& output, << " " << std::flush); } } - cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, cmCTestLogWrite(data, length)); + cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, + cmCTestLogWrite(strdata.c_str(), strdata.size())); + if (ofs) { + ofs << cmCTestLogWrite(strdata.c_str(), strdata.size()); + } + } + processOutput.DecodeText(std::string(), strdata); + if (!strdata.empty()) { + output.append(strdata); + cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, + cmCTestLogWrite(strdata.c_str(), strdata.size())); if (ofs) { - ofs << cmCTestLogWrite(data, length); + ofs << cmCTestLogWrite(strdata.c_str(), strdata.size()); } } cmCTestLog(this, HANDLER_PROGRESS_OUTPUT, " Size of output: " @@ -1061,7 +1075,7 @@ int cmCTest::RunMakeCommand(const char* command, std::string& output, int cmCTest::RunTest(std::vector<const char*> argv, std::string* output, int* retVal, std::ostream* log, double testTimeOut, - std::vector<std::string>* environment) + std::vector<std::string>* environment, Encoding encoding) { bool modifyEnv = (environment && !environment->empty()); @@ -1156,17 +1170,30 @@ int cmCTest::RunTest(std::vector<const char*> argv, std::string* output, char* data; int length; + cmProcessOutput processOutput(encoding); + std::string strdata; while (cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR)) { + processOutput.DecodeText(data, length, strdata); if (output) { tempOutput.insert(tempOutput.end(), data, data + length); } - cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, cmCTestLogWrite(data, length)); + cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, + cmCTestLogWrite(strdata.c_str(), strdata.size())); + if (log) { + log->write(strdata.c_str(), strdata.size()); + } + } + processOutput.DecodeText(std::string(), strdata); + if (!strdata.empty()) { + cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, + cmCTestLogWrite(strdata.c_str(), strdata.size())); if (log) { - log->write(data, length); + log->write(strdata.c_str(), strdata.size()); } } cmsysProcess_WaitForExit(cp, CM_NULLPTR); + processOutput.DecodeText(tempOutput, tempOutput); if (output && tempOutput.begin() != tempOutput.end()) { output->append(&*tempOutput.begin(), tempOutput.size()); } @@ -2496,7 +2523,7 @@ bool cmCTest::SetCTestConfigurationFromCMakeVariable( bool cmCTest::RunCommand(const char* command, std::string* stdOut, std::string* stdErr, int* retVal, const char* dir, - double timeout) + double timeout, Encoding encoding) { std::vector<std::string> args = cmSystemTools::ParseArguments(command); @@ -2527,6 +2554,8 @@ bool cmCTest::RunCommand(const char* command, std::string* stdOut, std::vector<char> tempError; char* data; int length; + cmProcessOutput processOutput(encoding); + std::string strdata; int res; bool done = false; while (!done) { @@ -2543,15 +2572,24 @@ bool cmCTest::RunCommand(const char* command, std::string* stdOut, } if ((res == cmsysProcess_Pipe_STDOUT || res == cmsysProcess_Pipe_STDERR) && this->ExtraVerbose) { - cmSystemTools::Stdout(data, length); + processOutput.DecodeText(data, length, strdata); + cmSystemTools::Stdout(strdata.c_str(), strdata.size()); + } + } + if (this->ExtraVerbose) { + processOutput.DecodeText(std::string(), strdata); + if (!strdata.empty()) { + cmSystemTools::Stdout(strdata.c_str(), strdata.size()); } } cmsysProcess_WaitForExit(cp, CM_NULLPTR); if (!tempOutput.empty()) { + processOutput.DecodeText(tempOutput, tempOutput); stdOut->append(&*tempOutput.begin(), tempOutput.size()); } if (!tempError.empty()) { + processOutput.DecodeText(tempError, tempError); stdErr->append(&*tempError.begin(), tempError.size()); } diff --git a/Source/cmCTest.h b/Source/cmCTest.h index e5b4728..8db2e5f 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -5,6 +5,7 @@ #include <cmConfigure.h> +#include <cmProcessOutput.h> #include <cmsys/String.hxx> #include <map> #include <set> @@ -13,6 +14,7 @@ #include <time.h> #include <vector> +class cmCTest; class cmCTestGenericHandler; class cmCTestStartCommand; class cmGeneratedFileStream; @@ -48,6 +50,7 @@ class cmCTest friend class cmCTestMultiProcessHandler; public: + typedef cmProcessOutput::Encoding Encoding; /** Enumerate parts of the testing and submission process. */ enum Part { @@ -267,7 +270,8 @@ public: */ bool RunCommand(const char* command, std::string* stdOut, std::string* stdErr, int* retVal = CM_NULLPTR, - const char* dir = CM_NULLPTR, double timeout = 0.0); + const char* dir = CM_NULLPTR, double timeout = 0.0, + Encoding encoding = cmProcessOutput::Auto); /** * Clean/make safe for xml the given value such that it may be used as @@ -286,7 +290,8 @@ public: * and retVal is return value or exception. */ int RunMakeCommand(const char* command, std::string& output, int* retVal, - const char* dir, int timeout, std::ostream& ofs); + const char* dir, int timeout, std::ostream& ofs, + Encoding encoding = cmProcessOutput::Auto); /** Return the current tag */ std::string GetCurrentTag(); @@ -333,7 +338,8 @@ public: */ int RunTest(std::vector<const char*> args, std::string* output, int* retVal, std::ostream* logfile, double testTimeOut, - std::vector<std::string>* environment); + std::vector<std::string>* environment, + Encoding encoding = cmProcessOutput::Auto); /** * Execute handler and return its result. If the handler fails, it returns diff --git a/Source/cmCallVisualStudioMacro.cxx b/Source/cmCallVisualStudioMacro.cxx index a21a7d2..99fe587 100644 --- a/Source/cmCallVisualStudioMacro.cxx +++ b/Source/cmCallVisualStudioMacro.cxx @@ -2,6 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCallVisualStudioMacro.h" +#include <sstream> + #include "cmSystemTools.h" #if defined(_MSC_VER) diff --git a/Source/cmCallVisualStudioMacro.h b/Source/cmCallVisualStudioMacro.h index 7ff4513..e9d34e5 100644 --- a/Source/cmCallVisualStudioMacro.h +++ b/Source/cmCallVisualStudioMacro.h @@ -5,7 +5,7 @@ #include <cmConfigure.h> -#include "cmStandardIncludes.h" +#include <string> /** \class cmCallVisualStudioMacro * \brief Control class for communicating with CMake's Visual Studio macros diff --git a/Source/cmCryptoHash.cxx b/Source/cmCryptoHash.cxx index f440999..d5807b1 100644 --- a/Source/cmCryptoHash.cxx +++ b/Source/cmCryptoHash.cxx @@ -9,12 +9,16 @@ static unsigned int const cmCryptoHashAlgoToId[] = { /* clang-format needs this comment to break after the opening brace */ - RHASH_MD5, // - RHASH_SHA1, // - RHASH_SHA224, // - RHASH_SHA256, // - RHASH_SHA384, // - RHASH_SHA512 + RHASH_MD5, // + RHASH_SHA1, // + RHASH_SHA224, // + RHASH_SHA256, // + RHASH_SHA384, // + RHASH_SHA512, // + RHASH_SHA3_224, // + RHASH_SHA3_256, // + RHASH_SHA3_384, // + RHASH_SHA3_512 }; static int cmCryptoHash_rhash_library_initialized; @@ -59,6 +63,18 @@ CM_AUTO_PTR<cmCryptoHash> cmCryptoHash::New(const char* algo) if (strcmp(algo, "SHA512") == 0) { return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoSHA512)); } + if (strcmp(algo, "SHA3_224") == 0) { + return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoSHA3_224)); + } + if (strcmp(algo, "SHA3_256") == 0) { + return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoSHA3_256)); + } + if (strcmp(algo, "SHA3_384") == 0) { + return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoSHA3_384)); + } + if (strcmp(algo, "SHA3_512") == 0) { + return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoSHA3_512)); + } return CM_AUTO_PTR<cmCryptoHash>(CM_NULLPTR); } diff --git a/Source/cmCryptoHash.h b/Source/cmCryptoHash.h index 95080ac..0b562da 100644 --- a/Source/cmCryptoHash.h +++ b/Source/cmCryptoHash.h @@ -3,12 +3,14 @@ #ifndef cmCryptoHash_h #define cmCryptoHash_h -#include <cmConfigure.h> +#include <cmConfigure.h> // IWYU pragma: keep -#include <cm_auto_ptr.hxx> +#include <stddef.h> #include <string> #include <vector> +#include "cm_auto_ptr.hxx" + /** * @brief Abstract base class for cryptographic hash generators */ @@ -22,7 +24,11 @@ public: AlgoSHA224, AlgoSHA256, AlgoSHA384, - AlgoSHA512 + AlgoSHA512, + AlgoSHA3_224, + AlgoSHA3_256, + AlgoSHA3_384, + AlgoSHA3_512 }; cmCryptoHash(Algo algo); @@ -30,7 +36,8 @@ public: /// @brief Returns a new hash generator of the requested type /// @arg algo Hash type name. Supported hash types are - /// MD5, SHA1, SHA224, SHA256, SHA384, SHA512 + /// MD5, SHA1, SHA224, SHA256, SHA384, SHA512, + /// SHA3_224, SHA3_256, SHA3_384, SHA3_512 /// @return A valid auto pointer if algo is supported or /// an invalid/NULL pointer otherwise static CM_AUTO_PTR<cmCryptoHash> New(const char* algo); diff --git a/Source/cmExecProgramCommand.cxx b/Source/cmExecProgramCommand.cxx index df92592..6a7292d 100644 --- a/Source/cmExecProgramCommand.cxx +++ b/Source/cmExecProgramCommand.cxx @@ -6,6 +6,7 @@ #include <stdio.h> #include "cmMakefile.h" +#include "cmProcessOutput.h" #include "cmSystemTools.h" class cmExecutionStatus; @@ -116,7 +117,7 @@ bool cmExecProgramCommand::InitialPass(std::vector<std::string> const& args, bool cmExecProgramCommand::RunCommand(const char* command, std::string& output, int& retVal, const char* dir, - bool verbose) + bool verbose, Encoding encoding) { if (cmSystemTools::GetRunCommandOutput()) { verbose = false; @@ -214,17 +215,28 @@ bool cmExecProgramCommand::RunCommand(const char* command, std::string& output, int length; char* data; int p; + cmProcessOutput processOutput(encoding); + std::string strdata; while ((p = cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR), p)) { if (p == cmsysProcess_Pipe_STDOUT || p == cmsysProcess_Pipe_STDERR) { if (verbose) { - cmSystemTools::Stdout(data, length); + processOutput.DecodeText(data, length, strdata); + cmSystemTools::Stdout(strdata.c_str(), strdata.size()); } output.append(data, length); } } + if (verbose) { + processOutput.DecodeText(std::string(), strdata); + if (!strdata.empty()) { + cmSystemTools::Stdout(strdata.c_str(), strdata.size()); + } + } + // All output has been read. Wait for the process to exit. cmsysProcess_WaitForExit(cp, CM_NULLPTR); + processOutput.DecodeText(output, output); // Check the result of running the process. std::string msg; diff --git a/Source/cmExecProgramCommand.h b/Source/cmExecProgramCommand.h index 7cdf777..58e948e 100644 --- a/Source/cmExecProgramCommand.h +++ b/Source/cmExecProgramCommand.h @@ -8,6 +8,7 @@ #include <vector> #include "cmCommand.h" +#include "cmProcessOutput.h" class cmExecutionStatus; @@ -21,6 +22,7 @@ class cmExecutionStatus; class cmExecProgramCommand : public cmCommand { public: + typedef cmProcessOutput::Encoding Encoding; /** * This is a virtual constructor for the command. */ @@ -46,7 +48,8 @@ public: private: static bool RunCommand(const char* command, std::string& output, int& retVal, const char* directory = CM_NULLPTR, - bool verbose = true); + bool verbose = true, + Encoding encoding = cmProcessOutput::Auto); }; #endif diff --git a/Source/cmExecuteProcessCommand.cxx b/Source/cmExecuteProcessCommand.cxx index c8a3a84..1562223 100644 --- a/Source/cmExecuteProcessCommand.cxx +++ b/Source/cmExecuteProcessCommand.cxx @@ -8,6 +8,7 @@ #include <stdio.h> #include "cmMakefile.h" +#include "cmProcessOutput.h" #include "cmSystemTools.h" class cmExecutionStatus; @@ -222,25 +223,43 @@ bool cmExecuteProcessCommand::InitialPass(std::vector<std::string> const& args, int length; char* data; int p; + cmProcessOutput processOutput; + std::string strdata; while ((p = cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR), p)) { // Put the output in the right place. if (p == cmsysProcess_Pipe_STDOUT && !output_quiet) { if (output_variable.empty()) { - cmSystemTools::Stdout(data, length); + processOutput.DecodeText(data, length, strdata, 1); + cmSystemTools::Stdout(strdata.c_str(), strdata.size()); } else { cmExecuteProcessCommandAppend(tempOutput, data, length); } } else if (p == cmsysProcess_Pipe_STDERR && !error_quiet) { if (error_variable.empty()) { - cmSystemTools::Stderr(data, length); + processOutput.DecodeText(data, length, strdata, 2); + cmSystemTools::Stderr(strdata.c_str(), strdata.size()); } else { cmExecuteProcessCommandAppend(tempError, data, length); } } } + if (!output_quiet && output_variable.empty()) { + processOutput.DecodeText(std::string(), strdata, 1); + if (!strdata.empty()) { + cmSystemTools::Stdout(strdata.c_str(), strdata.size()); + } + } + if (!error_quiet && error_variable.empty()) { + processOutput.DecodeText(std::string(), strdata, 2); + if (!strdata.empty()) { + cmSystemTools::Stderr(strdata.c_str(), strdata.size()); + } + } // All output has been read. Wait for the process to exit. cmsysProcess_WaitForExit(cp, CM_NULLPTR); + processOutput.DecodeText(tempOutput, tempOutput); + processOutput.DecodeText(tempError, tempError); // Fix the text in the output strings. cmExecuteProcessCommandFixText(tempOutput, output_strip_trailing_whitespace); diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index ff2703e..b4fc771 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -703,6 +703,14 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const * Also on the cdt-dev list didn't bring any information: * http://web.archiveorange.com/archive/v/B4NlJDNIpYoOS1SbxFNy * Alex */ + // include subprojects directory to the src pathentry + // eclipse cdt indexer uses this entries as reference to index source files + if (this->GenerateLinkedResources) { + xml.StartElement("pathentry"); + xml.Attribute("kind", "src"); + xml.Attribute("path", "[Subprojects]"); + xml.EndElement(); + } for (std::vector<std::string>::const_iterator it = this->SrcLinkedResources.begin(); diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 15257fc..2f6238b 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -2,15 +2,39 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmFileCommand.h" +#include <algorithm> +#include <assert.h> +#include <cm_kwiml.h> +#include <cmsys/Directory.hxx> +#include <cmsys/FStream.hxx> +#include <cmsys/Glob.hxx> +#include <cmsys/RegularExpression.hxx> +#include <cmsys/String.hxx> +#include <list> +#include <sstream> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <sys/types.h> +// include sys/stat.h after sys/types.h +#include <sys/stat.h> + #include "cmAlgorithms.h" +#include "cmCommandArgumentsHelper.h" #include "cmCryptoHash.h" -#include "cmCryptoHash.h" +#include "cmFileLockPool.h" #include "cmFileTimeComparison.h" +#include "cmGeneratorExpression.h" #include "cmGlobalGenerator.h" #include "cmHexFileConverter.h" #include "cmInstallType.h" +#include "cmListFileCache.h" #include "cmMakefile.h" +#include "cmPolicies.h" +#include "cmSystemTools.h" #include "cmTimestamp.h" +#include "cm_auto_ptr.hxx" #include "cmake.h" #if defined(CMAKE_BUILD_WITH_CMAKE) @@ -18,20 +42,7 @@ #include "cmFileLockResult.h" #endif -#undef GetCurrentDirectory -#include <assert.h> -#include <stdlib.h> - -#include <sys/types.h> -// include sys/stat.h after sys/types.h -#include <sys/stat.h> - -#include <cm_auto_ptr.hxx> -#include <cmsys/Directory.hxx> -#include <cmsys/Encoding.hxx> -#include <cmsys/FStream.hxx> -#include <cmsys/Glob.hxx> -#include <cmsys/RegularExpression.hxx> +class cmSystemToolsFileTime; // Table of permissions flags. #if defined(_WIN32) && !defined(__CYGWIN__) @@ -111,7 +122,9 @@ bool cmFileCommand::InitialPass(std::vector<std::string> const& args, } if (subCommand == "MD5" || subCommand == "SHA1" || subCommand == "SHA224" || subCommand == "SHA256" || subCommand == "SHA384" || - subCommand == "SHA512") { + subCommand == "SHA512" || subCommand == "SHA3_224" || + subCommand == "SHA3_256" || subCommand == "SHA3_384" || + subCommand == "SHA3_512") { return this->HandleHashCommand(args); } if (subCommand == "STRINGS") { diff --git a/Source/cmFileMonitor.cxx b/Source/cmFileMonitor.cxx index 9844306..03bbf42 100644 --- a/Source/cmFileMonitor.cxx +++ b/Source/cmFileMonitor.cxx @@ -291,7 +291,7 @@ void on_directory_change(uv_fs_event_t* handle, const char* filename, { const cmIBaseWatcher* const watcher = static_cast<const cmIBaseWatcher*>(handle->data); - const std::string pathSegment(filename); + const std::string pathSegment(filename ? filename : ""); watcher->Trigger(pathSegment, events, status); } diff --git a/Source/cmGhsMultiGpj.h b/Source/cmGhsMultiGpj.h index 793d471..2c2b123 100644 --- a/Source/cmGhsMultiGpj.h +++ b/Source/cmGhsMultiGpj.h @@ -5,8 +5,6 @@ #include <cmConfigure.h> -#include "cmStandardIncludes.h" - class cmGeneratedFileStream; class GhsMultiGpj diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index fa447ff..2808051 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -50,6 +50,9 @@ #include <cm_jsoncpp_writer.h> #endif +const std::string kCMAKE_PLATFORM_INFO_INITIALIZED = + "CMAKE_PLATFORM_INFO_INITIALIZED"; + class cmInstalledFile; bool cmTarget::StrictTargetComparison::operator()(cmTarget const* t1, @@ -428,6 +431,23 @@ void cmGlobalGenerator::EnableLanguage( // set the dir for parent files so they can be used by modules mf->AddDefinition("CMAKE_PLATFORM_INFO_DIR", rootBin.c_str()); + if (!this->CMakeInstance->GetIsInTryCompile()) { + // Keep a mark in the cache to indicate that we've initialized the + // platform information directory. If the platform information + // directory exists but the mark is missing then CMakeCache.txt + // has been removed or replaced without also removing the CMakeFiles/ + // directory. In this case remove the platform information directory + // so that it will be re-initialized and the relevant information + // restored in the cache. + if (cmSystemTools::FileIsDirectory(rootBin) && + !mf->IsOn(kCMAKE_PLATFORM_INFO_INITIALIZED)) { + cmSystemTools::RemoveADirectory(rootBin); + } + this->GetCMakeInstance()->AddCacheEntry( + kCMAKE_PLATFORM_INFO_INITIALIZED, "1", + "Platform information initialized", cmStateEnums::INTERNAL); + } + // find and make sure CMAKE_MAKE_PROGRAM is defined if (!this->FindMakeProgram(mf)) { return; diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index 6bbfed5..286f375 100644 --- a/Source/cmGlobalGhsMultiGenerator.cxx +++ b/Source/cmGlobalGhsMultiGenerator.cxx @@ -2,14 +2,16 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmGlobalGhsMultiGenerator.h" +#include <cmsys/SystemTools.hxx> + +#include "cmAlgorithms.h" +#include "cmDocumentationEntry.h" #include "cmGeneratedFileStream.h" #include "cmGeneratorTarget.h" #include "cmGhsMultiTargetGenerator.h" #include "cmLocalGhsMultiGenerator.h" #include "cmMakefile.h" #include "cmVersion.h" -#include <cmAlgorithms.h> -#include <cmsys/SystemTools.hxx> const char* cmGlobalGhsMultiGenerator::FILE_EXTENSION = ".gpj"; const char* cmGlobalGhsMultiGenerator::DEFAULT_MAKE_PROGRAM = "gbuild"; diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 2ce65cd..a1af6ff 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -1,10 +1,9 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#include "windows.h" // this must be first to define GetCurrentDirectory - #include "cmGlobalVisualStudio10Generator.h" #include "cmAlgorithms.h" +#include "cmDocumentationEntry.h" #include "cmGeneratorTarget.h" #include "cmLocalVisualStudio10Generator.h" #include "cmMakefile.h" diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index acd2c2b..049e86e 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -3,6 +3,7 @@ #include "cmGlobalVisualStudio11Generator.h" #include "cmAlgorithms.h" +#include "cmDocumentationEntry.h" #include "cmLocalVisualStudio10Generator.h" #include "cmMakefile.h" #include "cmVS11CLFlagTable.h" diff --git a/Source/cmGlobalVisualStudio11Generator.h b/Source/cmGlobalVisualStudio11Generator.h index be78544..ae99408 100644 --- a/Source/cmGlobalVisualStudio11Generator.h +++ b/Source/cmGlobalVisualStudio11Generator.h @@ -3,7 +3,18 @@ #ifndef cmGlobalVisualStudio11Generator_h #define cmGlobalVisualStudio11Generator_h +#include <cmConfigure.h> + +#include <iosfwd> +#include <set> +#include <string> + #include "cmGlobalVisualStudio10Generator.h" +#include "cmStateTypes.h" + +class cmGlobalGeneratorFactory; +class cmMakefile; +class cmake; /** \class cmGlobalVisualStudio11Generator */ class cmGlobalVisualStudio11Generator : public cmGlobalVisualStudio10Generator diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx index c18ff9e..0a48ba6 100644 --- a/Source/cmGlobalVisualStudio12Generator.cxx +++ b/Source/cmGlobalVisualStudio12Generator.cxx @@ -3,6 +3,7 @@ #include "cmGlobalVisualStudio12Generator.h" #include "cmAlgorithms.h" +#include "cmDocumentationEntry.h" #include "cmLocalVisualStudio10Generator.h" #include "cmMakefile.h" #include "cmVS12CLFlagTable.h" diff --git a/Source/cmGlobalVisualStudio12Generator.h b/Source/cmGlobalVisualStudio12Generator.h index cdda512..79efe52 100644 --- a/Source/cmGlobalVisualStudio12Generator.h +++ b/Source/cmGlobalVisualStudio12Generator.h @@ -3,8 +3,17 @@ #ifndef cmGlobalVisualStudio12Generator_h #define cmGlobalVisualStudio12Generator_h +#include <cmConfigure.h> + +#include <iosfwd> +#include <string> + #include "cmGlobalVisualStudio11Generator.h" +class cmGlobalGeneratorFactory; +class cmMakefile; +class cmake; + /** \class cmGlobalVisualStudio12Generator */ class cmGlobalVisualStudio12Generator : public cmGlobalVisualStudio11Generator { diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx index e0b86d7..b4cb823 100644 --- a/Source/cmGlobalVisualStudio14Generator.cxx +++ b/Source/cmGlobalVisualStudio14Generator.cxx @@ -3,6 +3,7 @@ #include "cmGlobalVisualStudio14Generator.h" #include "cmAlgorithms.h" +#include "cmDocumentationEntry.h" #include "cmLocalVisualStudio10Generator.h" #include "cmMakefile.h" #include "cmVS140CLFlagTable.h" diff --git a/Source/cmGlobalVisualStudio14Generator.h b/Source/cmGlobalVisualStudio14Generator.h index 991f018..ab22978 100644 --- a/Source/cmGlobalVisualStudio14Generator.h +++ b/Source/cmGlobalVisualStudio14Generator.h @@ -3,8 +3,17 @@ #ifndef cmGlobalVisualStudio14Generator_h #define cmGlobalVisualStudio14Generator_h +#include <cmConfigure.h> + +#include <iosfwd> +#include <string> + #include "cmGlobalVisualStudio12Generator.h" +class cmGlobalGeneratorFactory; +class cmMakefile; +class cmake; + /** \class cmGlobalVisualStudio14Generator */ class cmGlobalVisualStudio14Generator : public cmGlobalVisualStudio12Generator { diff --git a/Source/cmGlobalVisualStudio15Generator.cxx b/Source/cmGlobalVisualStudio15Generator.cxx index fbc7a10..19b48df 100644 --- a/Source/cmGlobalVisualStudio15Generator.cxx +++ b/Source/cmGlobalVisualStudio15Generator.cxx @@ -3,6 +3,7 @@ #include "cmGlobalVisualStudio15Generator.h" #include "cmAlgorithms.h" +#include "cmDocumentationEntry.h" #include "cmLocalVisualStudio10Generator.h" #include "cmMakefile.h" #include "cmVS141CLFlagTable.h" diff --git a/Source/cmGlobalVisualStudio15Generator.h b/Source/cmGlobalVisualStudio15Generator.h index 2e458f4..59eb11a 100644 --- a/Source/cmGlobalVisualStudio15Generator.h +++ b/Source/cmGlobalVisualStudio15Generator.h @@ -3,8 +3,16 @@ #ifndef cmGlobalVisualStudio15Generator_h #define cmGlobalVisualStudio15Generator_h +#include <cmConfigure.h> + +#include <iosfwd> +#include <string> + #include "cmGlobalVisualStudio14Generator.h" +class cmGlobalGeneratorFactory; +class cmake; + /** \class cmGlobalVisualStudio15Generator */ class cmGlobalVisualStudio15Generator : public cmGlobalVisualStudio14Generator { diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index 8af0512..55a788f 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -1,9 +1,8 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#include "windows.h" // this must be first to define GetCurrentDirectory - #include "cmGlobalVisualStudio71Generator.h" +#include "cmDocumentationEntry.h" #include "cmGeneratorTarget.h" #include "cmLocalVisualStudio7Generator.h" #include "cmMakefile.h" diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 64808c9..e961a3d 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -1,9 +1,8 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#include "windows.h" // this must be first to define GetCurrentDirectory - #include "cmGlobalVisualStudio8Generator.h" +#include "cmDocumentationEntry.h" #include "cmGeneratedFileStream.h" #include "cmGeneratorTarget.h" #include "cmLocalVisualStudio7Generator.h" @@ -161,6 +160,11 @@ void cmGlobalVisualStudio8Generator::GetDocumentation( entry.Brief = "Generates Visual Studio 8 2005 project files."; } +std::string cmGlobalVisualStudio8Generator::GetGenerateStampList() +{ + return "generate.stamp.list"; +} + void cmGlobalVisualStudio8Generator::Configure() { this->cmGlobalVisualStudio7Generator::Configure(); @@ -244,7 +248,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() // Create a list of all stamp files for this project. std::vector<std::string> stamps; std::string stampList = cmake::GetCMakeFilesDirectoryPostSlash(); - stampList += "generate.stamp.list"; + stampList += cmGlobalVisualStudio8Generator::GetGenerateStampList(); { std::string stampListFile = generators[0]->GetMakefile()->GetCurrentBinaryDirectory(); diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index b149c9d..53feb47 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -23,6 +23,9 @@ public: /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); + /** Get the name of the main stamp list file. */ + static std::string GetGenerateStampList(); + virtual void EnableLanguage(std::vector<std::string> const& languages, cmMakefile*, bool optional); virtual void AddPlatformDefinitions(cmMakefile* mf); diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx index 32ba849..b1634e2 100644 --- a/Source/cmGlobalVisualStudio9Generator.cxx +++ b/Source/cmGlobalVisualStudio9Generator.cxx @@ -1,9 +1,8 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#include "windows.h" // this must be first to define GetCurrentDirectory - #include "cmGlobalVisualStudio9Generator.h" +#include "cmDocumentationEntry.h" #include "cmLocalVisualStudio7Generator.h" #include "cmMakefile.h" #include "cmVisualStudioWCEPlatformParser.h" diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 354ada9..5edb81f 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -3,6 +3,9 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmGlobalVisualStudioGenerator.h" +#include <cmsys/Encoding.hxx> +#include <iostream> + #include "cmAlgorithms.h" #include "cmCallVisualStudioMacro.h" #include "cmGeneratedFileStream.h" @@ -12,7 +15,6 @@ #include "cmSourceFile.h" #include "cmState.h" #include "cmTarget.h" -#include <cmsys/Encoding.hxx> cmGlobalVisualStudioGenerator::cmGlobalVisualStudioGenerator(cmake* cm) : cmGlobalGenerator(cm) diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index 0e88bce..f32f0bb 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -3,7 +3,22 @@ #ifndef cmGlobalVisualStudioGenerator_h #define cmGlobalVisualStudioGenerator_h +#include <cmConfigure.h> + +#include <iosfwd> +#include <map> +#include <set> +#include <string> +#include <vector> + #include "cmGlobalGenerator.h" +#include "cmTargetDepend.h" + +class cmCustomCommand; +class cmGeneratorTarget; +class cmLocalGenerator; +class cmMakefile; +class cmake; /** \class cmGlobalVisualStudioGenerator * \brief Base class for global Visual Studio generators. diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 84a8c5e..50197c9 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2,20 +2,35 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmGlobalXCodeGenerator.h" -#include "cmAlgorithms.h" +#include <assert.h> +#include <cmsys/RegularExpression.hxx> +#include <iomanip> +#include <sstream> +#include <stdio.h> +#include <string.h> + #include "cmComputeLinkInformation.h" #include "cmCustomCommandGenerator.h" +#include "cmDocumentationEntry.h" #include "cmGeneratedFileStream.h" +#include "cmGeneratorExpression.h" #include "cmGeneratorTarget.h" #include "cmGlobalGeneratorFactory.h" +#include "cmLocalGenerator.h" #include "cmLocalXCodeGenerator.h" #include "cmMakefile.h" +#include "cmOutputConverter.h" #include "cmSourceFile.h" +#include "cmSourceGroup.h" +#include "cmStateTypes.h" +#include "cmSystemTools.h" +#include "cmTarget.h" #include "cmXCode21Object.h" #include "cmXCodeObject.h" +#include "cm_auto_ptr.hxx" #include "cmake.h" -#include <cm_auto_ptr.hxx> +struct cmLinkImplementation; #if defined(CMAKE_BUILD_WITH_CMAKE) #include "cmXMLParser.h" @@ -1925,40 +1940,24 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, BuildObjectListOrString dirs(this, this->XcodeVersion >= 30); BuildObjectListOrString fdirs(this, this->XcodeVersion >= 30); + std::vector<std::string> includes; + this->CurrentLocalGenerator->GetIncludeDirectories(includes, gtgt, "C", + configName); std::set<std::string> emitted; emitted.insert("/System/Library/Frameworks"); - if (this->XcodeVersion < 60) { - std::vector<std::string> includes; - this->CurrentLocalGenerator->GetIncludeDirectories(includes, gtgt, "C", - configName); - for (std::vector<std::string>::iterator i = includes.begin(); - i != includes.end(); ++i) { - if (this->NameResolvesToFramework(*i)) { - std::string frameworkDir = *i; - frameworkDir += "/../"; - frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir); - if (emitted.insert(frameworkDir).second) { - fdirs.Add(this->XCodeEscapePath(frameworkDir)); - } - } else { - std::string incpath = this->XCodeEscapePath(*i); - dirs.Add(incpath); - } - } - } else { - for (std::set<std::string>::iterator li = languages.begin(); - li != languages.end(); ++li) { - std::vector<std::string> includes; - this->CurrentLocalGenerator->GetIncludeDirectories(includes, gtgt, *li, - configName); - std::string includeFlags = this->CurrentLocalGenerator->GetIncludeFlags( - includes, gtgt, *li, true, false, configName); - - std::string& flags = cflags[*li]; - if (!includeFlags.empty()) { - flags += " " + includeFlags; + for (std::vector<std::string>::iterator i = includes.begin(); + i != includes.end(); ++i) { + if (this->NameResolvesToFramework(*i)) { + std::string frameworkDir = *i; + frameworkDir += "/../"; + frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir); + if (emitted.insert(frameworkDir).second) { + fdirs.Add(this->XCodeEscapePath(frameworkDir)); } + } else { + std::string incpath = this->XCodeEscapePath(*i); + dirs.Add(incpath); } } // Add framework search paths needed for linking. diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index ded8073..42c39aa 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -3,13 +3,25 @@ #ifndef cmGlobalXCodeGenerator_h #define cmGlobalXCodeGenerator_h -#include "cmGlobalGenerator.h" +#include <cmConfigure.h> +#include <iosfwd> +#include <map> +#include <set> +#include <string> +#include <vector> -#include "cmCustomCommand.h" +#include "cmGlobalGenerator.h" #include "cmXCodeObject.h" + +class cmCustomCommand; +class cmGeneratorTarget; class cmGlobalGeneratorFactory; +class cmLocalGenerator; +class cmMakefile; class cmSourceFile; class cmSourceGroup; +class cmake; +struct cmDocumentationEntry; /** \class cmGlobalXCodeGenerator * \brief Write a Unix makefiles. @@ -23,7 +35,7 @@ public: static cmGlobalGeneratorFactory* NewFactory(); ///! Get the name for the generator. - virtual std::string GetName() const + std::string GetName() const CM_OVERRIDE { return cmGlobalXCodeGenerator::GetActualName(); } @@ -33,51 +45,53 @@ public: static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf); + cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf) CM_OVERRIDE; /** * Try to determine system information such as shared library * extension, pthreads, byte order etc. */ - virtual void EnableLanguage(std::vector<std::string> const& languages, - cmMakefile*, bool optional); + void EnableLanguage(std::vector<std::string> const& languages, cmMakefile*, + bool optional) CM_OVERRIDE; /** * Try running cmake and building a file. This is used for dynalically * loaded commands, not as part of the usual build process. */ - virtual void GenerateBuildCommand( - std::vector<std::string>& makeCommand, const std::string& makeProgram, - const std::string& projectName, const std::string& projectDir, - const std::string& targetName, const std::string& config, bool fast, - bool verbose, - std::vector<std::string> const& makeOptions = std::vector<std::string>()); + void GenerateBuildCommand(std::vector<std::string>& makeCommand, + const std::string& makeProgram, + const std::string& projectName, + const std::string& projectDir, + const std::string& targetName, + const std::string& config, bool fast, bool verbose, + std::vector<std::string> const& makeOptions = + std::vector<std::string>()) CM_OVERRIDE; /** Append the subdirectory for the given configuration. */ - virtual void AppendDirectoryForConfig(const std::string& prefix, - const std::string& config, - const std::string& suffix, - std::string& dir); + void AppendDirectoryForConfig(const std::string& prefix, + const std::string& config, + const std::string& suffix, + std::string& dir) CM_OVERRIDE; bool FindMakeProgram(cmMakefile*) CM_OVERRIDE; ///! What is the configurations directory variable called? - virtual const char* GetCMakeCFGIntDir() const; + const char* GetCMakeCFGIntDir() const CM_OVERRIDE; ///! expand CFGIntDir - virtual std::string ExpandCFGIntDir(const std::string& str, - const std::string& config) const; + std::string ExpandCFGIntDir(const std::string& str, + const std::string& config) const CM_OVERRIDE; void SetCurrentLocalGenerator(cmLocalGenerator*); /** Return true if the generated build tree may contain multiple builds. i.e. "Can I build Debug and Release in the same tree?" */ - virtual bool IsMultiConfig() const; + bool IsMultiConfig() const CM_OVERRIDE; - virtual bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf); + bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf) CM_OVERRIDE; void AppendFlag(std::string& flags, std::string const& flag); protected: - virtual void AddExtraIDETargets(); - virtual void Generate(); + void AddExtraIDETargets() CM_OVERRIDE; + void Generate() CM_OVERRIDE; private: cmXCodeObject* CreateOrGetPBXGroup(cmGeneratorTarget* gtgt, @@ -120,7 +134,7 @@ private: cmXCodeObject* CreateFlatClone(cmXCodeObject*); cmXCodeObject* CreateXCodeTarget(cmGeneratorTarget* gtgt, cmXCodeObject* buildPhases); - void ForceLinkerLanguages(); + void ForceLinkerLanguages() CM_OVERRIDE; void ForceLinkerLanguage(cmGeneratorTarget* gtgt); const char* GetTargetLinkFlagsVar(const cmGeneratorTarget* target) const; const char* GetTargetFileType(cmGeneratorTarget* target); @@ -192,11 +206,11 @@ private: std::vector<std::string> const& defines, bool dflag = false); - void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; + void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const CM_OVERRIDE; protected: - virtual const char* GetInstallTargetName() const { return "install"; } - virtual const char* GetPackageTargetName() const { return "package"; } + const char* GetInstallTargetName() const CM_OVERRIDE { return "install"; } + const char* GetPackageTargetName() const CM_OVERRIDE { return "package"; } unsigned int XcodeVersion; std::string VersionString; @@ -211,7 +225,7 @@ private: bool XcodeBuildCommandInitialized; void PrintCompilerAdvice(std::ostream&, std::string const&, - const char*) const + const char*) const CM_OVERRIDE { } diff --git a/Source/cmIDEOptions.cxx b/Source/cmIDEOptions.cxx index 286076f..c6c0e05 100644 --- a/Source/cmIDEOptions.cxx +++ b/Source/cmIDEOptions.cxx @@ -2,9 +2,12 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmIDEOptions.h" -#include "cmSystemTools.h" - #include <cmsys/String.h> +#include <iterator> +#include <string.h> + +#include "cmIDEFlagTable.h" +#include "cmSystemTools.h" cmIDEOptions::cmIDEOptions() { diff --git a/Source/cmIDEOptions.h b/Source/cmIDEOptions.h index 1067c40..a0696e1 100644 --- a/Source/cmIDEOptions.h +++ b/Source/cmIDEOptions.h @@ -5,9 +5,11 @@ #include <cmConfigure.h> -#include "cmStandardIncludes.h" +#include <map> +#include <string> +#include <vector> -#include "cmIDEFlagTable.h" +struct cmIDEFlagTable; /** \class cmIDEOptions * \brief Superclass for IDE option processing diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 8d81d61..46e49dc 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -213,7 +213,14 @@ void cmLocalGenerator::TraceDependencies() void cmLocalGenerator::GenerateTestFiles() { + std::string file = this->StateSnapshot.GetDirectory().GetCurrentBinary(); + file += "/"; + file += "CTestTestfile.cmake"; + if (!this->Makefile->IsOn("CMAKE_TESTING_ENABLED")) { + if (cmSystemTools::FileExists(file)) { + cmSystemTools::RemoveFile(file); + } return; } @@ -222,10 +229,6 @@ void cmLocalGenerator::GenerateTestFiles() const std::string& config = this->Makefile->GetConfigurations(configurationTypes, false); - std::string file = this->StateSnapshot.GetDirectory().GetCurrentBinary(); - file += "/"; - file += "CTestTestfile.cmake"; - cmGeneratedFileStream fout(file.c_str()); fout.SetCopyIfDifferent(true); diff --git a/Source/cmLocalVisualStudio10Generator.h b/Source/cmLocalVisualStudio10Generator.h index 4becfee..1ed57ec 100644 --- a/Source/cmLocalVisualStudio10Generator.h +++ b/Source/cmLocalVisualStudio10Generator.h @@ -3,8 +3,15 @@ #ifndef cmLocalVisualStudio10Generator_h #define cmLocalVisualStudio10Generator_h +#include <cmConfigure.h> + +#include <string> + #include "cmLocalVisualStudio7Generator.h" +class cmGlobalGenerator; +class cmMakefile; + /** \class cmLocalVisualStudio10Generator * \brief Write Visual Studio 10 project files. * diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index 6665bb0..d69cce1 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -3,17 +3,23 @@ #ifndef cmLocalVisualStudio7Generator_h #define cmLocalVisualStudio7Generator_h -#include "cmLocalVisualStudioGenerator.h" +#include <cmConfigure.h> + +#include <iosfwd> +#include <string> +#include <vector> +#include "cmLocalVisualStudioGenerator.h" #include "cmVisualStudioGeneratorOptions.h" -class cmSourceFile; class cmCustomCommand; -class cmSourceGroup; - -class cmLocalVisualStudio7GeneratorOptions; +class cmGeneratorTarget; +class cmGlobalGenerator; class cmLocalVisualStudio7GeneratorFCInfo; class cmLocalVisualStudio7GeneratorInternals; +class cmMakefile; +class cmSourceFile; +class cmSourceGroup; /** \class cmLocalVisualStudio7Generator * \brief Write Visual Studio .NET project files. @@ -119,6 +125,7 @@ private: friend class cmLocalVisualStudio7GeneratorInternals; class EventWriter; + friend class EventWriter; std::string ModuleDefinitionFile; diff --git a/Source/cmLocalVisualStudioGenerator.h b/Source/cmLocalVisualStudioGenerator.h index 169ecaf..39188f9 100644 --- a/Source/cmLocalVisualStudioGenerator.h +++ b/Source/cmLocalVisualStudioGenerator.h @@ -3,16 +3,22 @@ #ifndef cmLocalVisualStudioGenerator_h #define cmLocalVisualStudioGenerator_h -#include "cmLocalGenerator.h" +#include <cmConfigure.h> -#include "cmGlobalVisualStudioGenerator.h" +#include <map> +#include <memory> +#include <string> -#include <cm_auto_ptr.hxx> +#include "cmGlobalVisualStudioGenerator.h" +#include "cmLocalGenerator.h" +#include "cm_auto_ptr.hxx" -class cmSourceFile; -class cmSourceGroup; class cmCustomCommand; class cmCustomCommandGenerator; +class cmGeneratorTarget; +class cmGlobalGenerator; +class cmMakefile; +class cmSourceFile; /** \class cmLocalVisualStudioGenerator * \brief Base class for Visual Studio generators. diff --git a/Source/cmLocalXCodeGenerator.cxx b/Source/cmLocalXCodeGenerator.cxx index b596a8f..739ef43 100644 --- a/Source/cmLocalXCodeGenerator.cxx +++ b/Source/cmLocalXCodeGenerator.cxx @@ -4,9 +4,12 @@ #include "cmGeneratorTarget.h" #include "cmGlobalXCodeGenerator.h" -#include "cmMakefile.h" #include "cmSourceFile.h" +class cmGeneratorTarget; +class cmGlobalGenerator; +class cmMakefile; + cmLocalXCodeGenerator::cmLocalXCodeGenerator(cmGlobalGenerator* gg, cmMakefile* mf) : cmLocalGenerator(gg, mf) diff --git a/Source/cmLocalXCodeGenerator.h b/Source/cmLocalXCodeGenerator.h index 3756b61..b4a8c6c 100644 --- a/Source/cmLocalXCodeGenerator.h +++ b/Source/cmLocalXCodeGenerator.h @@ -3,8 +3,17 @@ #ifndef cmLocalXCodeGenerator_h #define cmLocalXCodeGenerator_h +#include <cmConfigure.h> // IWYU pragma: keep +#include <map> +#include <string> + #include "cmLocalGenerator.h" +class cmGeneratorTarget; +class cmGlobalGenerator; +class cmMakefile; +class cmSourceFile; + /** \class cmLocalXCodeGenerator * \brief Write a local Xcode project * diff --git a/Source/cmMachO.cxx b/Source/cmMachO.cxx index 95518f9..586e6c6 100644 --- a/Source/cmMachO.cxx +++ b/Source/cmMachO.cxx @@ -1,10 +1,12 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#include "cmStandardIncludes.h" // to get CMAKE_USE_MACH_PARSER first - #include "cmMachO.h" +#include <algorithm> #include <cmsys/FStream.hxx> +#include <stddef.h> +#include <string> +#include <vector> // Include the Mach-O format information system header. #include <mach-o/fat.h> diff --git a/Source/cmMachO.h b/Source/cmMachO.h index a754c1f..901f17a 100644 --- a/Source/cmMachO.h +++ b/Source/cmMachO.h @@ -3,6 +3,11 @@ #ifndef cmMachO_h #define cmMachO_h +#include <cmConfigure.h> + +#include <iosfwd> +#include <string> + #if !defined(CMAKE_USE_MACH_PARSER) #error "This file may be included only if CMAKE_USE_MACH_PARSER is enabled." #endif diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index c34e826..6c5b2b2 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -480,6 +480,9 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd() std::vector<std::string> linkCmds; cmMakefile* mf = this->GetMakefile(); { + // If we have a rule variable prefer it. In the case of static libraries + // this occurs when things like IPO is enabled, and we need to use the + // CMAKE_<lang>_CREATE_STATIC_LIBRARY_IPO define instead. std::string linkCmdVar = this->GetGeneratorTarget()->GetCreateRuleVariable( this->TargetLinkLanguage, this->GetConfigName()); const char* linkCmd = mf->GetDefinition(linkCmdVar); diff --git a/Source/cmProcessOutput.cxx b/Source/cmProcessOutput.cxx new file mode 100644 index 0000000..1440223 --- /dev/null +++ b/Source/cmProcessOutput.cxx @@ -0,0 +1,155 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ + +#include "cmProcessOutput.h" + +#if defined(_WIN32) +#include <windows.h> +unsigned int cmProcessOutput::defaultCodepage = + KWSYS_ENCODING_DEFAULT_CODEPAGE; +#endif + +cmProcessOutput::cmProcessOutput(Encoding encoding, unsigned int maxSize) +{ +#if defined(_WIN32) + codepage = 0; + bufferSize = maxSize; + if (encoding == None) { + codepage = defaultCodepage; + } else if (encoding == Auto) { + codepage = GetConsoleCP(); + } else if (encoding == UTF8) { + codepage = CP_UTF8; + } else if (encoding == OEM) { + codepage = GetOEMCP(); + } + if (!codepage || encoding == ANSI) { + codepage = GetACP(); + } +#else + static_cast<void>(encoding); + static_cast<void>(maxSize); +#endif +} + +cmProcessOutput::~cmProcessOutput() +{ +} + +bool cmProcessOutput::DecodeText(std::string raw, std::string& decoded, + size_t id) +{ + bool success = true; + decoded = raw; +#if defined(_WIN32) + if (id > 0) { + if (rawparts.size() < id) { + rawparts.reserve(id); + while (rawparts.size() < id) + rawparts.push_back(std::string()); + } + raw = rawparts[id - 1] + raw; + rawparts[id - 1].clear(); + decoded = raw; + } + if (raw.size() > 0 && codepage != defaultCodepage) { + success = false; + CPINFOEXW cpinfo; + if (id > 0 && bufferSize > 0 && raw.size() == bufferSize && + GetCPInfoExW(codepage, 0, &cpinfo) == 1 && cpinfo.MaxCharSize > 1) { + if (cpinfo.MaxCharSize == 2 && cpinfo.LeadByte[0] != 0) { + LPSTR prevChar = + CharPrevExA(codepage, raw.c_str(), raw.c_str() + raw.size(), 0); + bool isLeadByte = + (*(prevChar + 1) == 0) && IsDBCSLeadByteEx(codepage, *prevChar); + if (isLeadByte) { + rawparts[id - 1] += *(raw.end() - 1); + raw.resize(raw.size() - 1); + } + success = DoDecodeText(raw, decoded, NULL); + } else { + bool restoreDecoded = false; + std::string firstDecoded = decoded; + wchar_t lastChar = 0; + for (UINT i = 0; i < cpinfo.MaxCharSize; i++) { + success = DoDecodeText(raw, decoded, &lastChar); + if (success && lastChar != 0) { + if (i == 0) { + firstDecoded = decoded; + } + if (lastChar == cpinfo.UnicodeDefaultChar) { + restoreDecoded = true; + rawparts[id - 1] = *(raw.end() - 1) + rawparts[id - 1]; + raw.resize(raw.size() - 1); + } else { + restoreDecoded = false; + break; + } + } else { + break; + } + } + if (restoreDecoded) { + decoded = firstDecoded; + rawparts[id - 1].clear(); + } + } + } else { + success = DoDecodeText(raw, decoded, NULL); + } + } +#else + static_cast<void>(id); +#endif + return success; +} + +bool cmProcessOutput::DecodeText(const char* data, size_t length, + std::string& decoded, size_t id) +{ + return DecodeText(std::string(data, length), decoded, id); +} + +bool cmProcessOutput::DecodeText(std::vector<char> raw, + std::vector<char>& decoded, size_t id) +{ + std::string str; + const bool success = + DecodeText(std::string(raw.begin(), raw.end()), str, id); + decoded.assign(str.begin(), str.end()); + return success; +} + +#if defined(_WIN32) +bool cmProcessOutput::DoDecodeText(std::string raw, std::string& decoded, + wchar_t* lastChar) +{ + bool success = false; + const int wlength = + MultiByteToWideChar(codepage, 0, raw.c_str(), int(raw.size()), NULL, 0); + wchar_t* wdata = new wchar_t[wlength]; + int r = MultiByteToWideChar(codepage, 0, raw.c_str(), int(raw.size()), wdata, + wlength); + if (r > 0) { + if (lastChar) { + *lastChar = 0; + if ((wlength >= 2 && wdata[wlength - 2] != wdata[wlength - 1]) || + wlength >= 1) { + *lastChar = wdata[wlength - 1]; + } + } + int length = WideCharToMultiByte(defaultCodepage, 0, wdata, wlength, NULL, + 0, NULL, NULL); + char* data = new char[length]; + r = WideCharToMultiByte(defaultCodepage, 0, wdata, wlength, data, length, + NULL, NULL); + if (r > 0) { + decoded = std::string(data, length); + success = true; + } + delete[] data; + } + delete[] wdata; + return success; +} +#endif diff --git a/Source/cmProcessOutput.h b/Source/cmProcessOutput.h new file mode 100644 index 0000000..6a4e7d5 --- /dev/null +++ b/Source/cmProcessOutput.h @@ -0,0 +1,81 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#ifndef cmProcessOutput_h +#define cmProcessOutput_h + +#include <cmConfigure.h> // IWYU pragma: keep + +#include <stddef.h> +#include <string> +#include <vector> + +/** \class cmProcessOutput + * \brief Decode text data to internal encoding. + * + * cmProcessOutput is used to decode text output from external process + * using external encoding to our internal encoding. + */ +class cmProcessOutput +{ +public: + enum Encoding + { + None, + Auto, + UTF8, + ANSI, + OEM + }; + + /// The code page that is used as internal encoding to which we will encode. + static unsigned int defaultCodepage; + + /** + * A class constructor. + * \param encoding external process encoding from which we will decode. + * \param maxSize a maximal size for process output buffer. It should match + * to KWSYSPE_PIPE_BUFFER_SIZE. If text we decode is same size as \a maxSize + * then we will check for incomplete character at end of buffer and + * we will not return last incomplete character. This character will be + * returned with next DecodeText() call. To disable this behavior specify + * 0 as \a maxSize. + */ + cmProcessOutput(Encoding encoding = Auto, unsigned int maxSize = 1024); + ~cmProcessOutput(); + /** + * Decode \a raw string using external encoding to internal + * encoding in \a decoded. + * \a id specifies which internal buffer to use. This is important when we + * are decoding both stdout and stderr from process output and we need to + * keep incomplete characters in separate buffers for each stream. + * \return true if successfully decoded \a raw to \a decoded or false if not. + */ + bool DecodeText(std::string raw, std::string& decoded, size_t id = 0); + /** + * Decode \a data with \a length from external encoding to internal + * encoding in \a decoded. + * \param data a pointer to process output text data. + * \param length a size of data buffer. + * \param decoded a string which will contain decoded text. + * \param id an internal buffer id to use. + * \return true if successfully decoded \a data to \a decoded or false if + * not. + */ + bool DecodeText(const char* data, size_t length, std::string& decoded, + size_t id = 0); + /** + * \overload + */ + bool DecodeText(std::vector<char> raw, std::vector<char>& decoded, + size_t id = 0); + +private: +#if defined(_WIN32) + unsigned int codepage; + unsigned int bufferSize; + std::vector<std::string> rawparts; + bool DoDecodeText(std::string raw, std::string& decoded, wchar_t* lastChar); +#endif +}; + +#endif diff --git a/Source/cmProcessTools.cxx b/Source/cmProcessTools.cxx index e7b6051..b756650 100644 --- a/Source/cmProcessTools.cxx +++ b/Source/cmProcessTools.cxx @@ -1,29 +1,46 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmProcessTools.h" +#include "cmProcessOutput.h" #include <cmsys/Process.h> #include <ostream> void cmProcessTools::RunProcess(struct cmsysProcess_s* cp, OutputParser* out, - OutputParser* err) + OutputParser* err, Encoding encoding) { cmsysProcess_Execute(cp); char* data = CM_NULLPTR; int length = 0; int p; + cmProcessOutput processOutput(encoding); + std::string strdata; while ((out || err) && (p = cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR), p)) { if (out && p == cmsysProcess_Pipe_STDOUT) { - if (!out->Process(data, length)) { + processOutput.DecodeText(data, length, strdata, 1); + if (!out->Process(strdata.c_str(), int(strdata.size()))) { out = CM_NULLPTR; } } else if (err && p == cmsysProcess_Pipe_STDERR) { - if (!err->Process(data, length)) { + processOutput.DecodeText(data, length, strdata, 2); + if (!err->Process(strdata.c_str(), int(strdata.size()))) { err = CM_NULLPTR; } } } + if (out) { + processOutput.DecodeText(std::string(), strdata, 1); + if (!strdata.empty()) { + out->Process(strdata.c_str(), int(strdata.size())); + } + } + if (err) { + processOutput.DecodeText(std::string(), strdata, 2); + if (!strdata.empty()) { + out->Process(strdata.c_str(), int(strdata.size())); + } + } cmsysProcess_WaitForExit(cp, CM_NULLPTR); } diff --git a/Source/cmProcessTools.h b/Source/cmProcessTools.h index e5a3fe9..df131b9 100644 --- a/Source/cmProcessTools.h +++ b/Source/cmProcessTools.h @@ -3,6 +3,7 @@ #ifndef cmProcessTools_h #define cmProcessTools_h +#include "cmProcessOutput.h" #include <cmConfigure.h> #include <iosfwd> @@ -16,6 +17,7 @@ class cmProcessTools { public: + typedef cmProcessOutput::Encoding Encoding; /** Abstract interface for process output parsers. */ class OutputParser { @@ -79,7 +81,8 @@ public: /** Run a process and send output to given parsers. */ static void RunProcess(struct cmsysProcess_s* cp, OutputParser* out, - OutputParser* err = CM_NULLPTR); + OutputParser* err = CM_NULLPTR, + Encoding encoding = cmProcessOutput::Auto); }; #endif diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx index 609ad2b..9a06f05 100644 --- a/Source/cmServerProtocol.cxx +++ b/Source/cmServerProtocol.cxx @@ -386,25 +386,9 @@ bool cmServerProtocol1_0::DoActivate(const cmServerRequest& request, return false; } - const std::string fullGeneratorName = - cmExternalMakefileProjectGenerator::CreateFullGeneratorName( - generator, extraGenerator); - - cm->SetGeneratorToolset(toolset); - cm->SetGeneratorPlatform(platform); - - cmGlobalGenerator* gg = cm->CreateGlobalGenerator(fullGeneratorName); - if (!gg) { - setErrorMessage( - errorMessage, - std::string("Could not set up the requested combination of \"") + - kGENERATOR_KEY + "\" and \"" + kEXTRA_GENERATOR_KEY + "\""); - return false; - } - - cm->SetGlobalGenerator(gg); - cm->SetHomeDirectory(sourceDirectory); - cm->SetHomeOutputDirectory(buildDirectory); + this->GeneratorInfo = + GeneratorInformation(generator, extraGenerator, toolset, platform, + sourceDirectory, buildDirectory); this->m_State = STATE_ACTIVE; return true; @@ -944,6 +928,13 @@ cmServerResponse cmServerProtocol1_0::ProcessConfigure( FileMonitor()->StopMonitoring(); + std::string errorMessage; + cmake* cm = this->CMakeInstance(); + this->GeneratorInfo.SetupGenerator(cm, &errorMessage); + if (!errorMessage.empty()) { + return request.ReportError(errorMessage); + } + // Make sure the types of cacheArguments matches (if given): std::vector<std::string> cacheArgs; bool cacheArgumentsError = false; @@ -968,15 +959,13 @@ cmServerResponse cmServerProtocol1_0::ProcessConfigure( "cacheArguments must be unset, a string or an array of strings."); } - cmake* cm = this->CMakeInstance(); std::string sourceDir = cm->GetHomeDirectory(); const std::string buildDir = cm->GetHomeOutputDirectory(); cmGlobalGenerator* gg = cm->GetGlobalGenerator(); if (buildDir.empty()) { - return request.ReportError( - "No build directory set via setGlobalSettings."); + return request.ReportError("No build directory set via Handshake."); } if (cm->LoadCache(buildDir)) { @@ -1051,14 +1040,12 @@ cmServerResponse cmServerProtocol1_0::ProcessGlobalSettings( obj[kWARN_UNUSED_CLI_KEY] = cm->GetWarnUnusedCli(); obj[kCHECK_SYSTEM_VARS_KEY] = cm->GetCheckSystemVars(); - obj[kSOURCE_DIRECTORY_KEY] = cm->GetHomeDirectory(); - obj[kBUILD_DIRECTORY_KEY] = cm->GetHomeOutputDirectory(); + obj[kSOURCE_DIRECTORY_KEY] = this->GeneratorInfo.SourceDirectory; + obj[kBUILD_DIRECTORY_KEY] = this->GeneratorInfo.BuildDirectory; // Currently used generator: - cmGlobalGenerator* gen = cm->GetGlobalGenerator(); - obj[kGENERATOR_KEY] = gen ? gen->GetName() : std::string(); - obj[kEXTRA_GENERATOR_KEY] = - gen ? gen->GetExtraGeneratorName() : std::string(); + obj[kGENERATOR_KEY] = this->GeneratorInfo.GeneratorName; + obj[kEXTRA_GENERATOR_KEY] = this->GeneratorInfo.ExtraGeneratorName; return request.Reply(obj); } @@ -1122,3 +1109,41 @@ cmServerResponse cmServerProtocol1_0::ProcessFileSystemWatchers( return request.Reply(result); } + +cmServerProtocol1_0::GeneratorInformation::GeneratorInformation( + const std::string& generatorName, const std::string& extraGeneratorName, + const std::string& toolset, const std::string& platform, + const std::string& sourceDirectory, const std::string& buildDirectory) + : GeneratorName(generatorName) + , ExtraGeneratorName(extraGeneratorName) + , Toolset(toolset) + , Platform(platform) + , SourceDirectory(sourceDirectory) + , BuildDirectory(buildDirectory) +{ +} + +void cmServerProtocol1_0::GeneratorInformation::SetupGenerator( + cmake* cm, std::string* errorMessage) +{ + const std::string fullGeneratorName = + cmExternalMakefileProjectGenerator::CreateFullGeneratorName( + GeneratorName, ExtraGeneratorName); + + cm->SetHomeDirectory(SourceDirectory); + cm->SetHomeOutputDirectory(BuildDirectory); + + cmGlobalGenerator* gg = cm->CreateGlobalGenerator(fullGeneratorName); + if (!gg) { + setErrorMessage( + errorMessage, + std::string("Could not set up the requested combination of \"") + + kGENERATOR_KEY + "\" and \"" + kEXTRA_GENERATOR_KEY + "\""); + return; + } + + cm->SetGlobalGenerator(gg); + + cm->SetGeneratorToolset(Toolset); + cm->SetGeneratorPlatform(Platform); +} diff --git a/Source/cmServerProtocol.h b/Source/cmServerProtocol.h index 5238d5d..027f145 100644 --- a/Source/cmServerProtocol.h +++ b/Source/cmServerProtocol.h @@ -131,4 +131,28 @@ private: State m_State = STATE_INACTIVE; bool m_isDirty = false; + + struct GeneratorInformation + { + public: + GeneratorInformation() = default; + GeneratorInformation(const std::string& generatorName, + const std::string& extraGeneratorName, + const std::string& toolset, + const std::string& platform, + const std::string& sourceDirectory, + const std::string& buildDirectory); + + void SetupGenerator(cmake* cm, std::string* errorMessage); + + std::string GeneratorName; + std::string ExtraGeneratorName; + std::string Toolset; + std::string Platform; + + std::string SourceDirectory; + std::string BuildDirectory; + }; + + GeneratorInformation GeneratorInfo; }; diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index f835445..603c990 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -36,7 +36,9 @@ bool cmStringCommand::InitialPass(std::vector<std::string> const& args, } if (subCommand == "MD5" || subCommand == "SHA1" || subCommand == "SHA224" || subCommand == "SHA256" || subCommand == "SHA384" || - subCommand == "SHA512") { + subCommand == "SHA512" || subCommand == "SHA3_224" || + subCommand == "SHA3_256" || subCommand == "SHA3_384" || + subCommand == "SHA3_512") { return this->HandleHashCommand(args); } if (subCommand == "TOLOWER") { diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 7738ab6..029594f 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -3,6 +3,7 @@ #include "cmSystemTools.h" #include "cmAlgorithms.h" +#include "cmProcessOutput.h" #if defined(CMAKE_BUILD_WITH_CMAKE) #include "cmArchiveWrite.h" @@ -573,7 +574,7 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command, std::string* captureStdOut, std::string* captureStdErr, int* retVal, const char* dir, OutputOption outputflag, - double timeout) + double timeout, Encoding encoding) { std::vector<const char*> argv; for (std::vector<std::string>::const_iterator a = command.begin(); @@ -609,6 +610,8 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command, char* data; int length; int pipe; + cmProcessOutput processOutput(encoding); + std::string strdata; if (outputflag != OUTPUT_PASSTHROUGH && (captureStdOut || captureStdErr || outputflag != OUTPUT_NONE)) { while ((pipe = cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR)) > @@ -624,28 +627,44 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command, if (pipe == cmsysProcess_Pipe_STDOUT) { if (outputflag != OUTPUT_NONE) { - cmSystemTools::Stdout(data, length); + processOutput.DecodeText(data, length, strdata, 1); + cmSystemTools::Stdout(strdata.c_str(), strdata.size()); } if (captureStdOut) { tempStdOut.insert(tempStdOut.end(), data, data + length); } } else if (pipe == cmsysProcess_Pipe_STDERR) { if (outputflag != OUTPUT_NONE) { - cmSystemTools::Stderr(data, length); + processOutput.DecodeText(data, length, strdata, 2); + cmSystemTools::Stderr(strdata.c_str(), strdata.size()); } if (captureStdErr) { tempStdErr.insert(tempStdErr.end(), data, data + length); } } } + + if (outputflag != OUTPUT_NONE) { + processOutput.DecodeText(std::string(), strdata, 1); + if (!strdata.empty()) { + cmSystemTools::Stdout(strdata.c_str(), strdata.size()); + } + processOutput.DecodeText(std::string(), strdata, 2); + if (!strdata.empty()) { + cmSystemTools::Stderr(strdata.c_str(), strdata.size()); + } + } } cmsysProcess_WaitForExit(cp, CM_NULLPTR); + if (captureStdOut) { captureStdOut->assign(tempStdOut.begin(), tempStdOut.end()); + processOutput.DecodeText(*captureStdOut, *captureStdOut); } if (captureStdErr) { captureStdErr->assign(tempStdErr.begin(), tempStdErr.end()); + processOutput.DecodeText(*captureStdErr, *captureStdErr); } bool result = true; @@ -1643,6 +1662,8 @@ int cmSystemTools::WaitForLine(cmsysProcess* process, std::string& line, line = ""; std::vector<char>::iterator outiter = out.begin(); std::vector<char>::iterator erriter = err.begin(); + cmProcessOutput processOutput; + std::string strdata; while (1) { // Check for a newline in stdout. for (; outiter != out.end(); ++outiter) { @@ -1687,17 +1708,31 @@ int cmSystemTools::WaitForLine(cmsysProcess* process, std::string& line, return pipe; } if (pipe == cmsysProcess_Pipe_STDOUT) { + processOutput.DecodeText(data, length, strdata, 1); // Append to the stdout buffer. std::vector<char>::size_type size = out.size(); - out.insert(out.end(), data, data + length); + out.insert(out.end(), strdata.begin(), strdata.end()); outiter = out.begin() + size; } else if (pipe == cmsysProcess_Pipe_STDERR) { + processOutput.DecodeText(data, length, strdata, 2); // Append to the stderr buffer. std::vector<char>::size_type size = err.size(); - err.insert(err.end(), data, data + length); + err.insert(err.end(), strdata.begin(), strdata.end()); erriter = err.begin() + size; } else if (pipe == cmsysProcess_Pipe_None) { // Both stdout and stderr pipes have broken. Return leftover data. + processOutput.DecodeText(std::string(), strdata, 1); + if (!strdata.empty()) { + std::vector<char>::size_type size = out.size(); + out.insert(out.end(), strdata.begin(), strdata.end()); + outiter = out.begin() + size; + } + processOutput.DecodeText(std::string(), strdata, 2); + if (!strdata.empty()) { + std::vector<char>::size_type size = err.size(); + err.insert(err.end(), strdata.begin(), strdata.end()); + erriter = err.begin() + size; + } if (!out.empty()) { line.append(&out[0], outiter - out.begin()); out.erase(out.begin(), out.end()); diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 0801f26..10e8280 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -5,6 +5,7 @@ #include <cmConfigure.h> // IWYU pragma: keep +#include <cmProcessOutput.h> #include <cmsys/Process.h> #include <cmsys/SystemTools.hxx> #include <stddef.h> @@ -29,6 +30,7 @@ class cmSystemTools : public cmsys::SystemTools { public: typedef cmsys::SystemTools Superclass; + typedef cmProcessOutput::Encoding Encoding; /** Expand out any arguments in the vector that have ; separated * strings into multiple arguments. A new vector is created @@ -239,7 +241,8 @@ public: int* retVal = CM_NULLPTR, const char* dir = CM_NULLPTR, OutputOption outputflag = OUTPUT_MERGE, - double timeout = 0.0); + double timeout = 0.0, + Encoding encoding = cmProcessOutput::Auto); static std::string PrintSingleCommand(std::vector<std::string> const&); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 3741c33..ee4ff39 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -253,7 +253,6 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, this->SetPropertyDefault("WIN32_EXECUTABLE", CM_NULLPTR); this->SetPropertyDefault("MACOSX_BUNDLE", CM_NULLPTR); this->SetPropertyDefault("MACOSX_RPATH", CM_NULLPTR); - this->SetPropertyDefault("NO_SYSTEM_FROM_IMPORTED", CM_NULLPTR); this->SetPropertyDefault("C_CLANG_TIDY", CM_NULLPTR); this->SetPropertyDefault("C_COMPILER_LAUNCHER", CM_NULLPTR); this->SetPropertyDefault("C_INCLUDE_WHAT_YOU_USE", CM_NULLPTR); @@ -274,6 +273,10 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, this->SetPropertyDefault("LINK_SEARCH_END_STATIC", CM_NULLPTR); } + if (this->GetType() != cmStateEnums::UTILITY) { + this->SetPropertyDefault("NO_SYSTEM_FROM_IMPORTED", CM_NULLPTR); + } + // Collect the set of configuration types. std::vector<std::string> configNames; mf->GetConfigurations(configNames); diff --git a/Source/cmTargetPropertyComputer.cxx b/Source/cmTargetPropertyComputer.cxx index 3a9bddb..a57bc5a 100644 --- a/Source/cmTargetPropertyComputer.cxx +++ b/Source/cmTargetPropertyComputer.cxx @@ -66,6 +66,7 @@ bool cmTargetPropertyComputer::WhiteListedInterfaceProperty( } if (prop == "IMPORTED_CONFIGURATIONS" || prop == "IMPORTED_LIBNAME" || + prop == "NO_SYSTEM_FROM_IMPORTED" || cmHasLiteralPrefix(prop, "IMPORTED_LIBNAME_") || cmHasLiteralPrefix(prop, "MAP_IMPORTED_CONFIG_")) { return true; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 5dd9e48..4dabd51 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -314,6 +314,16 @@ void cmVisualStudio10TargetGenerator::Generate() << "</TargetFrameworkVersion>\n"; } + // Disable the project upgrade prompt that is displayed the first time a + // project using an older toolset version is opened in a newer version of + // the IDE (respected by VS 2013 and above). + if (this->GlobalGenerator->GetVersion() >= + cmGlobalVisualStudioGenerator::VS12) { + this->WriteString("<VCProjectUpgraderObjectName>NoUpgrade" + "</VCProjectUpgraderObjectName>\n", + 2); + } + std::vector<std::string> keys = this->GeneratorTarget->GetPropertyKeys(); for (std::vector<std::string>::const_iterator keyIt = keys.begin(); keyIt != keys.end(); ++keyIt) { diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 1fa844c..a4e3adb 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -5,19 +5,22 @@ #include <cmConfigure.h> -#include "cmStandardIncludes.h" +#include <iosfwd> +#include <map> +#include <set> +#include <string> +#include <vector> -class cmMakefile; -class cmGeneratorTarget; +class cmComputeLinkInformation; +class cmCustomCommand; class cmGeneratedFileStream; +class cmGeneratorTarget; class cmGlobalVisualStudio10Generator; -class cmSourceFile; -class cmCustomCommand; class cmLocalVisualStudio7Generator; -class cmComputeLinkInformation; +class cmMakefile; +class cmSourceFile; +class cmSourceGroup; class cmVisualStudioGeneratorOptions; -struct cmIDEFlagTable; -#include "cmSourceGroup.h" class cmVisualStudio10TargetGenerator { diff --git a/Source/cmVisualStudio10ToolsetOptions.h b/Source/cmVisualStudio10ToolsetOptions.h index ea6c9c8..bb0be15 100644 --- a/Source/cmVisualStudio10ToolsetOptions.h +++ b/Source/cmVisualStudio10ToolsetOptions.h @@ -3,7 +3,9 @@ #ifndef cmVisualStudio10ToolsetOptions_h #define cmVisualStudio10ToolsetOptions_h -#include "cmStandardIncludes.h" +#include <cmConfigure.h> + +#include <string> struct cmIDEFlagTable; diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index e751bfc..62200ce 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -1,5 +1,6 @@ #include "cmVisualStudioGeneratorOptions.h" +#include "cmLocalVisualStudioGenerator.h" #include "cmOutputConverter.h" #include "cmSystemTools.h" #include "cmVisualStudio10TargetGenerator.h" diff --git a/Source/cmVisualStudioGeneratorOptions.h b/Source/cmVisualStudioGeneratorOptions.h index 0a0b96d..e27c5d3 100644 --- a/Source/cmVisualStudioGeneratorOptions.h +++ b/Source/cmVisualStudioGeneratorOptions.h @@ -3,9 +3,17 @@ #ifndef cmVisualStudioGeneratorOptions_h #define cmVisualStudioGeneratorOptions_h -#include "cmLocalVisualStudioGenerator.h" +#include <cmConfigure.h> +#include <iosfwd> +#include <string> + +#include "cmGlobalVisualStudioGenerator.h" +#include "cmIDEFlagTable.h" #include "cmIDEOptions.h" + +class cmLocalVisualStudioGenerator; + typedef cmIDEFlagTable cmVS7FlagTable; class cmVisualStudio10TargetGenerator; diff --git a/Source/cmVisualStudioSlnData.h b/Source/cmVisualStudioSlnData.h index 9f5ccb7..b2f8db9 100644 --- a/Source/cmVisualStudioSlnData.h +++ b/Source/cmVisualStudioSlnData.h @@ -5,7 +5,9 @@ #include <cmConfigure.h> -#include "cmStandardIncludes.h" +#include <map> +#include <string> +#include <vector> class cmSlnProjectEntry { diff --git a/Source/cmVisualStudioSlnParser.h b/Source/cmVisualStudioSlnParser.h index 8939ab5..a3391a6 100644 --- a/Source/cmVisualStudioSlnParser.h +++ b/Source/cmVisualStudioSlnParser.h @@ -5,9 +5,10 @@ #include <cmConfigure.h> -#include "cmStandardIncludes.h" - #include <bitset> +#include <iosfwd> +#include <stddef.h> +#include <string> class cmSlnData; @@ -65,6 +66,7 @@ public: protected: class State; + friend class State; class ParsedLine; diff --git a/Source/cmVisualStudioWCEPlatformParser.h b/Source/cmVisualStudioWCEPlatformParser.h index 25f1a18..8ed6083 100644 --- a/Source/cmVisualStudioWCEPlatformParser.h +++ b/Source/cmVisualStudioWCEPlatformParser.h @@ -5,7 +5,10 @@ #include <cmConfigure.h> -#include "cmStandardIncludes.h" +#include <map> +#include <stddef.h> +#include <string> +#include <vector> #include "cmXMLParser.h" diff --git a/Source/cmXCode21Object.cxx b/Source/cmXCode21Object.cxx index a783c70..719e627 100644 --- a/Source/cmXCode21Object.cxx +++ b/Source/cmXCode21Object.cxx @@ -2,6 +2,9 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmXCode21Object.h" +#include <ostream> +#include <string> + #include "cmSystemTools.h" cmXCode21Object::cmXCode21Object(PBXType ptype, Type type) diff --git a/Source/cmXCode21Object.h b/Source/cmXCode21Object.h index 0db20e6..083d229 100644 --- a/Source/cmXCode21Object.h +++ b/Source/cmXCode21Object.h @@ -3,6 +3,11 @@ #ifndef cmXCode21Object_h #define cmXCode21Object_h +#include <cmConfigure.h> // IWYU pragma: keep + +#include <iosfwd> +#include <vector> + #include "cmXCodeObject.h" class cmXCode21Object : public cmXCodeObject diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx index b1dc7ea..3689ac4 100644 --- a/Source/cmXCodeObject.cxx +++ b/Source/cmXCodeObject.cxx @@ -2,9 +2,10 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmXCodeObject.h" -#include "cmSystemTools.h" +#include <CoreFoundation/CoreFoundation.h> +#include <ostream> -#include <CoreFoundation/CoreFoundation.h> // CFUUIDCreate +#include "cmSystemTools.h" const char* cmXCodeObject::PBXTypeNames[] = { /* clang-format needs this comment to break after the opening brace */ diff --git a/Source/cmXCodeObject.h b/Source/cmXCodeObject.h index d495130..3bfecdf 100644 --- a/Source/cmXCodeObject.h +++ b/Source/cmXCodeObject.h @@ -3,9 +3,14 @@ #ifndef cmXCodeObject_h #define cmXCodeObject_h -#include <cmConfigure.h> +#include <cmConfigure.h> // IWYU pragma: keep -#include "cmStandardIncludes.h" +#include <algorithm> +#include <iosfwd> +#include <map> +#include <string> +#include <utility> +#include <vector> class cmGeneratorTarget; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 6c066c6..59290ff 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -129,8 +129,8 @@ typedef CM_UNORDERED_MAP<std::string, Json::Value> JsonValueMapType; } // namespace -static bool cmakeCheckStampFile(const char* stampName); -static bool cmakeCheckStampList(const char* stampName); +static bool cmakeCheckStampFile(const char* stampName, bool verbose = true); +static bool cmakeCheckStampList(const char* stampList, bool verbose = true); void cmWarnUnusedCliWarning(const std::string& variable, int /*unused*/, void* ctx, const char* /*unused*/, @@ -2233,7 +2233,7 @@ int cmake::GetSystemInformation(std::vector<std::string>& args) return 0; } -static bool cmakeCheckStampFile(const char* stampName) +static bool cmakeCheckStampFile(const char* stampName, bool verbose) { // The stamp file does not exist. Use the stamp dependencies to // determine whether it is really out of date. This works in @@ -2287,11 +2287,13 @@ static bool cmakeCheckStampFile(const char* stampName) stamp << "# CMake generation timestamp file for this directory.\n"; } if (cmSystemTools::RenameFile(stampTemp, stampName)) { - // Notify the user why CMake is not re-running. It is safe to - // just print to stdout here because this code is only reachable - // through an undocumented flag used by the VS generator. - std::cout << "CMake does not need to re-run because " << stampName - << " is up-to-date.\n"; + if (verbose) { + // Notify the user why CMake is not re-running. It is safe to + // just print to stdout here because this code is only reachable + // through an undocumented flag used by the VS generator. + std::cout << "CMake does not need to re-run because " << stampName + << " is up-to-date.\n"; + } return true; } cmSystemTools::RemoveFile(stampTemp); @@ -2299,7 +2301,7 @@ static bool cmakeCheckStampFile(const char* stampName) return false; } -static bool cmakeCheckStampList(const char* stampList) +static bool cmakeCheckStampList(const char* stampList, bool verbose) { // If the stamp list does not exist CMake must rerun to generate it. if (!cmSystemTools::FileExists(stampList)) { @@ -2317,7 +2319,7 @@ static bool cmakeCheckStampList(const char* stampList) // Check each stamp. std::string stampName; while (cmSystemTools::GetLineFromStream(fin, stampName)) { - if (!cmakeCheckStampFile(stampName.c_str())) { + if (!cmakeCheckStampFile(stampName.c_str(), verbose)) { return false; } } @@ -2397,6 +2399,48 @@ int cmake::Build(const std::string& dir, const std::string& target, if (cachedVerbose) { verbose = cmSystemTools::IsOn(cachedVerbose); } + +#ifdef CMAKE_HAVE_VS_GENERATORS + // For VS generators, explicitly check if regeneration is necessary before + // actually starting the build. If not done separately from the build + // itself, there is the risk of building an out-of-date solution file due + // to limitations of the underlying build system. + std::string const stampList = cachePath + "/" + + GetCMakeFilesDirectoryPostSlash() + + cmGlobalVisualStudio8Generator::GetGenerateStampList(); + + // Note that the stampList file only exists for VS generators. + if (cmSystemTools::FileExists(stampList.c_str()) && + !cmakeCheckStampList(stampList.c_str(), false)) { + + // Correctly initialize the home (=source) and home output (=binary) + // directories, which is required for running the generation step. + std::string homeOrig = this->GetHomeDirectory(); + std::string homeOutputOrig = this->GetHomeOutputDirectory(); + this->SetDirectoriesFromFile(cachePath.c_str()); + + int ret = this->Configure(); + if (ret) { + cmSystemTools::Message("CMake Configure step failed. " + "Build files cannot be regenerated correctly."); + return ret; + } + ret = this->Generate(); + if (ret) { + cmSystemTools::Message("CMake Generate step failed. " + "Build files cannot be regenerated correctly."); + return ret; + } + std::string message = "Build files have been written to: "; + message += this->GetHomeOutputDirectory(); + this->UpdateProgress(message.c_str(), -1); + + // Restore the previously set directories to their original value. + this->SetHomeDirectory(homeOrig); + this->SetHomeOutputDirectory(homeOutputOrig); + } +#endif + return gen->Build("", dir, projName, target, output, "", config, clean, false, verbose, 0, cmSystemTools::OUTPUT_PASSTHROUGH, nativeOptions); diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index a974061..dee288c 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -407,6 +407,8 @@ static int do_build(int ac, char const* const* av) } cmake cm; + cmSystemTools::SetMessageCallback(cmakemainMessageCallback, (void*)&cm); + cm.SetProgressCallback(cmakemainProgressCallback, (void*)&cm); return cm.Build(dir, target, config, nativeOptions, clean); #endif } diff --git a/Source/cmakexbuild.cxx b/Source/cmakexbuild.cxx index 82db012..e166bee 100644 --- a/Source/cmakexbuild.cxx +++ b/Source/cmakexbuild.cxx @@ -1,9 +1,14 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#include "cmStandardIncludes.h" -#include "cmSystemTools.h" +#include <cmConfigure.h> // IWYU pragma: keep + #include <cmsys/Process.h> +#include <iostream> +#include <string> +#include <vector> + +#include "cmSystemTools.h" // This is a wrapper program for xcodebuild // it calls xcodebuild, and does two things diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 1db147a..f1ce75a 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -327,6 +327,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) iwyu_cmd.insert(iwyu_cmd.end(), orig_cmd.begin() + 1, orig_cmd.end()); // Run the iwyu command line. Capture its stderr and hide its stdout. + // Ignore its return code because the tool always returns non-zero. std::string stdErr; if (!cmSystemTools::RunSingleCommand(iwyu_cmd, CM_NULLPTR, &stdErr, &ret, CM_NULLPTR, @@ -357,14 +358,21 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) // Run the tidy command line. Capture its stdout and hide its stderr. std::string stdOut; - if (!cmSystemTools::RunSingleCommand(tidy_cmd, &stdOut, CM_NULLPTR, - &ret, CM_NULLPTR, + std::string stdErr; + if (!cmSystemTools::RunSingleCommand(tidy_cmd, &stdOut, &stdErr, &ret, + CM_NULLPTR, cmSystemTools::OUTPUT_NONE)) { - std::cerr << "Error running '" << tidy_cmd[0] << "'\n"; + std::cerr << "Error running '" << tidy_cmd[0] << "': " << stdErr + << "\n"; return 1; } // Output the stdout from clang-tidy to stderr std::cerr << stdOut; + // If clang-tidy exited with an error do the same. + if (ret != 0) { + std::cerr << stdErr; + return ret; + } } if (!lwyu.empty()) { // Construct the ldd -r -u (link what you use lwyu) command line @@ -377,11 +385,15 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) // Run the ldd -u -r command line. // Capture its stdout and hide its stderr. + // Ignore its return code because the tool always returns non-zero + // if there are any warnings, but we just want to warn. std::string stdOut; - if (!cmSystemTools::RunSingleCommand(lwyu_cmd, &stdOut, CM_NULLPTR, - &ret, CM_NULLPTR, + std::string stdErr; + if (!cmSystemTools::RunSingleCommand(lwyu_cmd, &stdOut, &stdErr, &ret, + CM_NULLPTR, cmSystemTools::OUTPUT_NONE)) { - std::cerr << "Error running '" << lwyu_cmd[0] << "'\n"; + std::cerr << "Error running '" << lwyu_cmd[0] << "': " << stdErr + << "\n"; return 1; } diff --git a/Source/kwsys/ConsoleBuf.hxx.in b/Source/kwsys/ConsoleBuf.hxx.in index 34c69a0..717462e 100644 --- a/Source/kwsys/ConsoleBuf.hxx.in +++ b/Source/kwsys/ConsoleBuf.hxx.in @@ -48,6 +48,17 @@ public: }; } + BasicConsoleBuf<CharT, Traits>* GetConsoleBuf() { return m_consolebuf; } + + void SetUTF8Pipes() + { + if (m_consolebuf) { + m_consolebuf->input_pipe_codepage = CP_UTF8; + m_consolebuf->output_pipe_codepage = CP_UTF8; + m_consolebuf->activateCodepageChange(); + } + } + ~Manager() { if (m_consolebuf) { diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx index 1675da5..e01dcd7 100644 --- a/Source/kwsys/SystemInformation.cxx +++ b/Source/kwsys/SystemInformation.cxx @@ -79,6 +79,7 @@ typedef int siginfo_t; #include <sys/sysctl.h> #if defined(KWSYS_SYS_HAS_IFADDRS_H) #include <ifaddrs.h> +#include <net/if.h> #define KWSYS_SYSTEMINFORMATION_IMPLEMENT_FQDN #endif #endif @@ -99,6 +100,7 @@ typedef int siginfo_t; #include <sys/sysctl.h> #if defined(KWSYS_SYS_HAS_IFADDRS_H) #include <ifaddrs.h> +#include <net/if.h> #define KWSYS_SYSTEMINFORMATION_IMPLEMENT_FQDN #endif #if !(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ - 0 >= 1050) @@ -113,6 +115,7 @@ typedef int siginfo_t; #include <sys/socket.h> #if defined(KWSYS_SYS_HAS_IFADDRS_H) #include <ifaddrs.h> +#include <net/if.h> #if !defined(__LSB_VERSION__) /* LSB has no getifaddrs */ #define KWSYS_SYSTEMINFORMATION_IMPLEMENT_FQDN #endif @@ -1696,7 +1699,9 @@ int SystemInformationImplementation::GetFullyQualifiedDomainName( for (ifa = ifas; ifa != NULL; ifa = ifa->ifa_next) { int fam = ifa->ifa_addr ? ifa->ifa_addr->sa_family : -1; - if ((fam == AF_INET) || (fam == AF_INET6)) { + // Skip Loopback interfaces + if (((fam == AF_INET) || (fam == AF_INET6)) && + !(ifa->ifa_flags & IFF_LOOPBACK)) { char host[NI_MAXHOST] = { '\0' }; const size_t addrlen = (fam == AF_INET ? sizeof(struct sockaddr_in) diff --git a/Source/kwsys/Terminal.c b/Source/kwsys/Terminal.c index 26174a1..c0b7f45 100644 --- a/Source/kwsys/Terminal.c +++ b/Source/kwsys/Terminal.c @@ -150,6 +150,8 @@ static const char* kwsysTerminalVT100Names[] = { "Eterm", "screen-bce", "screen-w", "screen.linux", + "tmux", + "tmux-256color", "vt100", "xterm", "xterm-16color", diff --git a/Tests/CMakeLib/run_compile_commands.cxx b/Tests/CMakeLib/run_compile_commands.cxx index 0bf0a7c..5d4ca70 100644 --- a/Tests/CMakeLib/run_compile_commands.cxx +++ b/Tests/CMakeLib/run_compile_commands.cxx @@ -1,4 +1,4 @@ -#include "cmSystemTools.h" +#include <cmConfigure.h> #include <cmsys/FStream.hxx> #include <iostream> @@ -8,6 +8,8 @@ #include <utility> #include <vector> +#include "cmSystemTools.h" + class CompileCommandParser { public: diff --git a/Tests/CMakeLib/testFindPackageCommand.cxx b/Tests/CMakeLib/testFindPackageCommand.cxx index 7622756..bfd429f 100644 --- a/Tests/CMakeLib/testFindPackageCommand.cxx +++ b/Tests/CMakeLib/testFindPackageCommand.cxx @@ -1,9 +1,13 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#include "cmFindPackageCommand.h" + +#include <cmConfigure.h> // IWYU pragma: keep #include <iostream> #include <string> +#include <vector> + +#include "cmFindPackageCommand.h" #define cmPassed(m) std::cout << "Passed: " << (m) << "\n" #define cmFailed(m) \ diff --git a/Tests/CMakeLib/testSystemTools.cxx b/Tests/CMakeLib/testSystemTools.cxx index b16b088..0dfa326 100644 --- a/Tests/CMakeLib/testSystemTools.cxx +++ b/Tests/CMakeLib/testSystemTools.cxx @@ -1,9 +1,14 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#include "cmSystemTools.h" + +#include <cmConfigure.h> // IWYU pragma: keep #include <iostream> +#include <stddef.h> #include <string> +#include <vector> + +#include "cmSystemTools.h" #define cmPassed(m) std::cout << "Passed: " << (m) << "\n" #define cmFailed(m) \ diff --git a/Tests/CMakeLib/testXMLSafe.cxx b/Tests/CMakeLib/testXMLSafe.cxx index 6c59128..fe776c5 100644 --- a/Tests/CMakeLib/testXMLSafe.cxx +++ b/Tests/CMakeLib/testXMLSafe.cxx @@ -1,11 +1,14 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#include "cmXMLSafe.h" + +#include <cmConfigure.h> #include <sstream> #include <stdio.h> #include <string> +#include "cmXMLSafe.h" + struct test_pair { const char* in; diff --git a/Tests/CMakeTests/File-SHA3_224-Works.cmake b/Tests/CMakeTests/File-SHA3_224-Works.cmake new file mode 100644 index 0000000..e4f4e85 --- /dev/null +++ b/Tests/CMakeTests/File-SHA3_224-Works.cmake @@ -0,0 +1,2 @@ +file(SHA3_224 ${CMAKE_CURRENT_LIST_DIR}/File-HASH-Input.txt sha3_224) +message("${sha3_224}") diff --git a/Tests/CMakeTests/File-SHA3_256-Works.cmake b/Tests/CMakeTests/File-SHA3_256-Works.cmake new file mode 100644 index 0000000..189c8a2 --- /dev/null +++ b/Tests/CMakeTests/File-SHA3_256-Works.cmake @@ -0,0 +1,2 @@ +file(SHA3_256 ${CMAKE_CURRENT_LIST_DIR}/File-HASH-Input.txt sha3_256) +message("${sha3_256}") diff --git a/Tests/CMakeTests/File-SHA3_384-Works.cmake b/Tests/CMakeTests/File-SHA3_384-Works.cmake new file mode 100644 index 0000000..08f9f5b --- /dev/null +++ b/Tests/CMakeTests/File-SHA3_384-Works.cmake @@ -0,0 +1,2 @@ +file(SHA3_384 ${CMAKE_CURRENT_LIST_DIR}/File-HASH-Input.txt sha3_384) +message("${sha3_384}") diff --git a/Tests/CMakeTests/File-SHA3_512-Works.cmake b/Tests/CMakeTests/File-SHA3_512-Works.cmake new file mode 100644 index 0000000..4182196 --- /dev/null +++ b/Tests/CMakeTests/File-SHA3_512-Works.cmake @@ -0,0 +1,2 @@ +file(SHA3_512 ${CMAKE_CURRENT_LIST_DIR}/File-HASH-Input.txt sha3_512) +message("${sha3_512}") diff --git a/Tests/CMakeTests/FileTest.cmake.in b/Tests/CMakeTests/FileTest.cmake.in index 61523e6..71cb3db 100644 --- a/Tests/CMakeTests/FileTest.cmake.in +++ b/Tests/CMakeTests/FileTest.cmake.in @@ -36,6 +36,14 @@ set(SHA384-Works-RESULT 0) set(SHA384-Works-STDERR "1de9560b4e030e02051ea408200ffc55d70c97ac64ebf822461a5c786f495c36df43259b14483bc8d364f0106f4971ee") set(SHA512-Works-RESULT 0) set(SHA512-Works-STDERR "3982a1b4e651768bec70ab1fb97045cb7a659f4ba7203d501c52ab2e803071f9d5fd272022df15f27727fc67f8cd022e710e29010b2a9c0b467c111e2f6abf51") +set(SHA3_224-Works-RESULT 0) +set(SHA3_224-Works-STDERR "4272868085f4f25080681a7712509fd12e16dcda79bd356836dd2100") +set(SHA3_256-Works-RESULT 0) +set(SHA3_256-Works-STDERR "be0df472b6bd474417a166d12f2774f2ef5095e86f0a88ef4c78c703800cfc8a") +set(SHA3_384-Works-RESULT 0) +set(SHA3_384-Works-STDERR "935a17cc708443c1369549483656a4521af03a52e4f3b314566272017ccae03a2c5db838f6d4c156b1dc5c366182481b") +set(SHA3_512-Works-RESULT 0) +set(SHA3_512-Works-STDERR "471a85ed537e8f77f31412a089f22d836054ffa179599f87a5d7568927d8fa236b6793ded8a387d1de92398c967177bcc6361672a722bf736cb0f63a0956d5cf") set(TIMESTAMP-NoFile-RESULT 0) set(TIMESTAMP-NoFile-STDERR "~~") set(TIMESTAMP-BadArg1-RESULT 1) @@ -66,6 +74,10 @@ check_cmake_test(File SHA256-Works SHA384-Works SHA512-Works + SHA3_224-Works + SHA3_256-Works + SHA3_384-Works + SHA3_512-Works TIMESTAMP-NoFile TIMESTAMP-BadArg1 TIMESTAMP-NotBogus diff --git a/Tests/CMakeTests/String-SHA3_224-Works.cmake b/Tests/CMakeTests/String-SHA3_224-Works.cmake new file mode 100644 index 0000000..6aeb91d --- /dev/null +++ b/Tests/CMakeTests/String-SHA3_224-Works.cmake @@ -0,0 +1,2 @@ +string(SHA3_224 sha3_224 "sample input string\n") +message("${sha3_224}") diff --git a/Tests/CMakeTests/String-SHA3_256-Works.cmake b/Tests/CMakeTests/String-SHA3_256-Works.cmake new file mode 100644 index 0000000..cc7ea1a --- /dev/null +++ b/Tests/CMakeTests/String-SHA3_256-Works.cmake @@ -0,0 +1,2 @@ +string(SHA3_256 sha3_256 "sample input string\n") +message("${sha3_256}") diff --git a/Tests/CMakeTests/String-SHA3_384-Works.cmake b/Tests/CMakeTests/String-SHA3_384-Works.cmake new file mode 100644 index 0000000..9341c3f --- /dev/null +++ b/Tests/CMakeTests/String-SHA3_384-Works.cmake @@ -0,0 +1,2 @@ +string(SHA3_384 sha3_384 "sample input string\n") +message("${sha3_384}") diff --git a/Tests/CMakeTests/String-SHA3_512-Works.cmake b/Tests/CMakeTests/String-SHA3_512-Works.cmake new file mode 100644 index 0000000..cf4eddd --- /dev/null +++ b/Tests/CMakeTests/String-SHA3_512-Works.cmake @@ -0,0 +1,2 @@ +string(SHA3_512 sha3_512 "sample input string\n") +message("${sha3_512}") diff --git a/Tests/CMakeTests/StringTest.cmake.in b/Tests/CMakeTests/StringTest.cmake.in index a45b205..83655da 100644 --- a/Tests/CMakeTests/StringTest.cmake.in +++ b/Tests/CMakeTests/StringTest.cmake.in @@ -16,6 +16,14 @@ set(SHA384-Works-RESULT 0) set(SHA384-Works-STDERR "1de9560b4e030e02051ea408200ffc55d70c97ac64ebf822461a5c786f495c36df43259b14483bc8d364f0106f4971ee") set(SHA512-Works-RESULT 0) set(SHA512-Works-STDERR "3982a1b4e651768bec70ab1fb97045cb7a659f4ba7203d501c52ab2e803071f9d5fd272022df15f27727fc67f8cd022e710e29010b2a9c0b467c111e2f6abf51") +set(SHA3_224-Works-RESULT 0) +set(SHA3_224-Works-STDERR "4272868085f4f25080681a7712509fd12e16dcda79bd356836dd2100") +set(SHA3_256-Works-RESULT 0) +set(SHA3_256-Works-STDERR "be0df472b6bd474417a166d12f2774f2ef5095e86f0a88ef4c78c703800cfc8a") +set(SHA3_384-Works-RESULT 0) +set(SHA3_384-Works-STDERR "935a17cc708443c1369549483656a4521af03a52e4f3b314566272017ccae03a2c5db838f6d4c156b1dc5c366182481b") +set(SHA3_512-Works-RESULT 0) +set(SHA3_512-Works-STDERR "471a85ed537e8f77f31412a089f22d836054ffa179599f87a5d7568927d8fa236b6793ded8a387d1de92398c967177bcc6361672a722bf736cb0f63a0956d5cf") set(TIMESTAMP-BadArg1-RESULT 1) set(TIMESTAMP-BadArg1-STDERR "string sub-command TIMESTAMP requires at least one argument") set(TIMESTAMP-BadArg2-RESULT 1) @@ -52,6 +60,10 @@ check_cmake_test(String SHA256-Works SHA384-Works SHA512-Works + SHA3_224-Works + SHA3_256-Works + SHA3_384-Works + SHA3_512-Works TIMESTAMP-BadArg1 TIMESTAMP-BadArg2 TIMESTAMP-BadArg3 diff --git a/Tests/ExternalProjectLocal/CMakeLists.txt b/Tests/ExternalProjectLocal/CMakeLists.txt index 17f1630..5b94163 100644 --- a/Tests/ExternalProjectLocal/CMakeLists.txt +++ b/Tests/ExternalProjectLocal/CMakeLists.txt @@ -131,6 +131,7 @@ ExternalProject_Add(${proj} CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR> INSTALL_COMMAND "" LOG_BUILD 1 + UPDATE_DISCONNECTED 1 ) set_property(TARGET ${proj} PROPERTY FOLDER "Local/TGZ") diff --git a/Tests/IncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/CMakeLists.txt index db18462..4920582 100644 --- a/Tests/IncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/CMakeLists.txt @@ -3,9 +3,7 @@ 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" - OR (CMAKE_GENERATOR STREQUAL "Xcode" AND NOT XCODE_VERSION VERSION_LESS 6.0))) + AND (CMAKE_GENERATOR STREQUAL "Unix Makefiles" OR CMAKE_GENERATOR STREQUAL "Ninja")) 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 5078f30..dcee85e 100644 --- a/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt @@ -15,17 +15,10 @@ target_include_directories(upstream SYSTEM PUBLIC ) add_library(config_specific INTERFACE) -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() +set(testConfig ${CMAKE_BUILD_TYPE}) +target_include_directories(config_specific SYSTEM INTERFACE + "$<$<CONFIG:${testConfig}>:${CMAKE_CURRENT_SOURCE_DIR}/config_specific>" +) add_library(consumer consumer.cpp) target_link_libraries(consumer upstream config_specific) diff --git a/Tests/InterfaceLibrary/CMakeLists.txt b/Tests/InterfaceLibrary/CMakeLists.txt index 3db210a..33c4b90 100644 --- a/Tests/InterfaceLibrary/CMakeLists.txt +++ b/Tests/InterfaceLibrary/CMakeLists.txt @@ -64,6 +64,7 @@ target_link_libraries(iface_whitelist INTERFACE $<$<BOOL:$<TARGET_PROPERTY:CUSTO add_executable(exec_whitelist dummy.cpp) target_link_libraries(exec_whitelist iface_whitelist) +set(CMAKE_NO_SYSTEM_FROM_IMPORTED 1) add_library(iface_imported INTERFACE IMPORTED) set_property(TARGET iface_imported PROPERTY INTERFACE_COMPILE_DEFINITIONS diff --git a/Tests/Module/ExternalData/SHA3_256/.gitattributes b/Tests/Module/ExternalData/SHA3_256/.gitattributes new file mode 100644 index 0000000..3e51d39 --- /dev/null +++ b/Tests/Module/ExternalData/SHA3_256/.gitattributes @@ -0,0 +1 @@ +* -crlf diff --git a/Tests/Module/ExternalData/SHA3_256/c01b0bfd51ece4295c7b45493750a3612ecc483095eb1366f9f46b179550e231 b/Tests/Module/ExternalData/SHA3_256/c01b0bfd51ece4295c7b45493750a3612ecc483095eb1366f9f46b179550e231 new file mode 100644 index 0000000..0377f5d --- /dev/null +++ b/Tests/Module/ExternalData/SHA3_256/c01b0bfd51ece4295c7b45493750a3612ecc483095eb1366f9f46b179550e231 @@ -0,0 +1 @@ +SeriesMixed.5 diff --git a/Tests/Module/ExternalData/SeriesMixed.5.dat.sha3-256 b/Tests/Module/ExternalData/SeriesMixed.5.dat.sha3-256 new file mode 100644 index 0000000..1a5db39 --- /dev/null +++ b/Tests/Module/ExternalData/SeriesMixed.5.dat.sha3-256 @@ -0,0 +1 @@ +c01b0bfd51ece4295c7b45493750a3612ecc483095eb1366f9f46b179550e231 diff --git a/Tests/RunCMake/Android/common.cmake b/Tests/RunCMake/Android/common.cmake index d803c98..bef2428 100644 --- a/Tests/RunCMake/Android/common.cmake +++ b/Tests/RunCMake/Android/common.cmake @@ -22,8 +22,23 @@ string(APPEND CMAKE_CXX_FLAGS " -Werror -Wno-attributes") string(APPEND CMAKE_EXE_LINKER_FLAGS " -Wl,-no-undefined") if(CMAKE_ANDROID_NDK) - if(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION MATCHES "clang") + if(NOT CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION) + message(SEND_ERROR "CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION is not set!") + elseif(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION MATCHES "^clang") add_definitions(-DCOMPILER_IS_CLANG) + elseif(NOT "${CMAKE_C_COMPILER}" MATCHES "toolchains/[^/]+-${CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION}/prebuilt") + message(SEND_ERROR "CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION is\n" + " ${CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION}\n" + "which does not appear in CMAKE_C_COMPILER:\n" + " ${CMAKE_C_COMPILER}") + endif() + if(NOT CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG) + message(SEND_ERROR "CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG is not set!") + elseif(NOT "${CMAKE_C_COMPILER}" MATCHES "prebuilt/${CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG}/bin") + message(SEND_ERROR "CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG is\n" + " ${CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG}\n" + "which does not appear in CMAKE_C_COMPILER:\n" + " ${CMAKE_C_COMPILER}") endif() elseif(CMAKE_ANDROID_STANDALONE_TOOLCHAIN) execute_process( @@ -37,6 +52,23 @@ elseif(CMAKE_ANDROID_STANDALONE_TOOLCHAIN) endif() endif() +execute_process( + COMMAND "${CMAKE_C_ANDROID_TOOLCHAIN_PREFIX}gcc${CMAKE_C_ANDROID_TOOLCHAIN_SUFFIX}" -dumpmachine + OUTPUT_VARIABLE _out OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE _err + RESULT_VARIABLE _res + ) +if(NOT _res EQUAL 0) + message(SEND_ERROR "Failed to run 'gcc -dumpmachine':\n ${_res}") +endif() +if(NOT _out STREQUAL "${CMAKE_C_ANDROID_TOOLCHAIN_MACHINE}") + message(SEND_ERROR "'gcc -dumpmachine' produced:\n" + " ${_out}\n" + "which is not equal to CMAKE_C_ANDROID_TOOLCHAIN_MACHINE:\n" + " ${CMAKE_C_ANDROID_TOOLCHAIN_MACHINE}" + ) +endif() + if(CMAKE_ANDROID_STL_TYPE STREQUAL "none") add_definitions(-DSTL_NONE) elseif(CMAKE_ANDROID_STL_TYPE STREQUAL "system") diff --git a/Tests/RunCMake/CPack/CMakeLists.txt b/Tests/RunCMake/CPack/CMakeLists.txt index e42e971..c361af0 100644 --- a/Tests/RunCMake/CPack/CMakeLists.txt +++ b/Tests/RunCMake/CPack/CMakeLists.txt @@ -1,12 +1,17 @@ cmake_minimum_required(VERSION 3.1 FATAL_ERROR) +set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "") + project(${RunCMake_TEST} CXX) -include(${RunCMake_TEST_FILE_PREFIX}.cmake) -# include test generator specifics -if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${GENERATOR_TYPE}/${RunCMake_TEST_FILE_PREFIX}-specifics.cmake") - include("${GENERATOR_TYPE}/${RunCMake_TEST_FILE_PREFIX}-specifics.cmake") +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${GENERATOR_TYPE}/packaging_${PACKAGING_TYPE}_default.cmake") + include(${GENERATOR_TYPE}/packaging_${PACKAGING_TYPE}_default.cmake) endif() +# set default test name (can be overwritten in test.cmake or specifics.cmake) +string(TOLOWER "${RunCMake_TEST_FILE_PREFIX}" CPACK_PACKAGE_NAME) + +include(tests/${RunCMake_TEST_FILE_PREFIX}/test.cmake) + set(CPACK_GENERATOR "${GENERATOR_TYPE}") include(CPack) diff --git a/Tests/RunCMake/CPack/COMPONENTS_EMPTY_DIR.cmake b/Tests/RunCMake/CPack/COMPONENTS_EMPTY_DIR.cmake deleted file mode 100644 index 7210e7d..0000000 --- a/Tests/RunCMake/CPack/COMPONENTS_EMPTY_DIR.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(CPACK_COMPONENTS_ALL test) -install(DIRECTORY DESTINATION empty - COMPONENT test) - -set(CPACK_PACKAGE_NAME "components_empty_dir") diff --git a/Tests/RunCMake/CPack/CPackTestHelpers.cmake b/Tests/RunCMake/CPack/CPackTestHelpers.cmake index 7e6b4b1..89da610 100644 --- a/Tests/RunCMake/CPack/CPackTestHelpers.cmake +++ b/Tests/RunCMake/CPack/CPackTestHelpers.cmake @@ -1,6 +1,6 @@ cmake_policy(SET CMP0057 NEW) -function(run_cpack_test_common_ TEST_NAME types build SUBTEST_SUFFIX source) +function(run_cpack_test_common_ TEST_NAME types build SUBTEST_SUFFIX source PACKAGING_TYPE) if(TEST_TYPE IN_LIST types) set(RunCMake_TEST_NO_CLEAN TRUE) set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${TEST_NAME}-build") @@ -11,16 +11,17 @@ function(run_cpack_test_common_ TEST_NAME types build SUBTEST_SUFFIX source) set(full_test_name_ "${full_test_name_}-${SUBTEST_SUFFIX}-subtest") endif() + string(APPEND full_test_name_ "-${PACKAGING_TYPE}-type") + # TODO this should be executed only once per ctest run (not per generator) file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") - if(EXISTS "${RunCMake_SOURCE_DIR}/${TEST_TYPE}/${TEST_NAME}-Prerequirements.cmake") - include("${RunCMake_SOURCE_DIR}/${TEST_TYPE}/${TEST_NAME}-Prerequirements.cmake") + if(EXISTS "${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${TEST_TYPE}-Prerequirements.cmake") + include("${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${TEST_TYPE}-Prerequirements.cmake") set(FOUND_PREREQUIREMENTS false) - get_test_prerequirements("FOUND_PREREQUIREMENTS" - "${TEST_CONFIG_DIR}/${type}_config.cmake") + get_test_prerequirements("FOUND_PREREQUIREMENTS" "${config_file}") # skip the test if prerequirements are not met if(NOT FOUND_PREREQUIREMENTS) @@ -32,7 +33,8 @@ function(run_cpack_test_common_ TEST_NAME types build SUBTEST_SUFFIX source) # execute cmake set(RunCMake_TEST_OPTIONS "-DGENERATOR_TYPE=${TEST_TYPE}" "-DRunCMake_TEST_FILE_PREFIX=${TEST_NAME}" - "-DRunCMake_SUBTEST_SUFFIX=${SUBTEST_SUFFIX}") + "-DRunCMake_SUBTEST_SUFFIX=${SUBTEST_SUFFIX}" + "-DPACKAGING_TYPE=${PACKAGING_TYPE}") run_cmake(${full_test_name_}) # execute optional build step @@ -43,7 +45,7 @@ function(run_cpack_test_common_ TEST_NAME types build SUBTEST_SUFFIX source) if(source) set(pack_params_ -G ${TEST_TYPE} --config ./CPackSourceConfig.cmake) FILE(APPEND ${RunCMake_TEST_BINARY_DIR}/CPackSourceConfig.cmake - "\nset(CPACK_RPM_SOURCE_PKG_BUILD_PARAMS \"-DRunCMake_TEST:STRING=${full_test_name_}\ -DRunCMake_TEST_FILE_PREFIX:STRING=${TEST_NAME}\")") + "\nset(CPACK_RPM_SOURCE_PKG_BUILD_PARAMS \"-DRunCMake_TEST:STRING=${full_test_name_} -DRunCMake_TEST_FILE_PREFIX:STRING=${TEST_NAME} -DGENERATOR_TYPE:STRING=${TEST_TYPE}\")") else() unset(pack_params_) endif() @@ -58,10 +60,12 @@ function(run_cpack_test_common_ TEST_NAME types build SUBTEST_SUFFIX source) ) foreach(o out err) - if(SUBTEST_SUFFIX AND EXISTS ${RunCMake_SOURCE_DIR}/${TEST_TYPE}/${TEST_NAME}-${SUBTEST_SUFFIX}-std${o}.txt) - set(RunCMake-std${o}-file "${TEST_TYPE}/${TEST_NAME}-${SUBTEST_SUFFIX}-std${o}.txt") - elseif(EXISTS ${RunCMake_SOURCE_DIR}/${TEST_TYPE}/${TEST_NAME}-std${o}.txt) - set(RunCMake-std${o}-file "${TEST_TYPE}/${TEST_NAME}-std${o}.txt") + if(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") + elseif(EXISTS ${RunCMake_SOURCE_DIR}/${TEST_TYPE}/default_expected_std${o}.txt) + set(RunCMake-std${o}-file "${TEST_TYPE}/default_expected_std${o}.txt") endif() endforeach() @@ -73,6 +77,7 @@ function(run_cpack_test_common_ TEST_NAME types build SUBTEST_SUFFIX source) -DRunCMake_TEST_FILE_PREFIX=${TEST_NAME} -DRunCMake_SUBTEST_SUFFIX=${SUBTEST_SUFFIX} -DGENERATOR_TYPE=${TEST_TYPE} + -DPACKAGING_TYPE=${PACKAGING_TYPE} "-Dsrc_dir=${RunCMake_SOURCE_DIR}" "-Dbin_dir=${RunCMake_TEST_BINARY_DIR}" "-Dconfig_file=${config_file}" @@ -81,16 +86,20 @@ function(run_cpack_test_common_ TEST_NAME types build SUBTEST_SUFFIX source) endif() endfunction() -function(run_cpack_test TEST_NAME types build) - run_cpack_test_common_("${TEST_NAME}" "${types}" "${build}" "" false) -endfunction() - -function(run_cpack_source_test TEST_NAME types build) - run_cpack_test_common_("${TEST_NAME}" "${types}" "${build}" "" true) +function(run_cpack_test TEST_NAME types build PACKAGING_TYPES) + foreach(packaging_type_ IN LISTS PACKAGING_TYPES) + run_cpack_test_common_("${TEST_NAME}" "${types}" "${build}" "" false "${packaging_type_}") + endforeach() endfunction() -function(run_cpack_test_subtests TEST_NAME SUBTEST_SUFFIXES types build) +function(run_cpack_test_subtests TEST_NAME SUBTEST_SUFFIXES types build PACKAGING_TYPES) foreach(suffix_ IN LISTS SUBTEST_SUFFIXES) - run_cpack_test_common_("${TEST_NAME}" "${types}" "${build}" "${suffix_}" false) + foreach(packaging_type_ IN LISTS PACKAGING_TYPES) + run_cpack_test_common_("${TEST_NAME}" "${types}" "${build}" "${suffix_}" false "${packaging_type_}") + endforeach() endforeach() endfunction() + +function(run_cpack_source_test TEST_NAME types) + run_cpack_test_common_("${TEST_NAME}" "${types}" false "" true "") +endfunction() diff --git a/Tests/RunCMake/CPack/CUSTOM_NAMES.cmake b/Tests/RunCMake/CPack/CUSTOM_NAMES.cmake deleted file mode 100644 index c89df89..0000000 --- a/Tests/RunCMake/CPack/CUSTOM_NAMES.cmake +++ /dev/null @@ -1,7 +0,0 @@ -set(CPACK_RPM_COMPONENT_INSTALL "ON") - -install(FILES CMakeLists.txt DESTINATION foo COMPONENT pkg_1) -install(FILES CMakeLists.txt DESTINATION foo COMPONENT pkg_2) -install(FILES CMakeLists.txt DESTINATION foo COMPONENT pkg_3) - -set(CPACK_PACKAGE_NAME "custom_names") diff --git a/Tests/RunCMake/CPack/DEB/COMPONENTS_EMPTY_DIR-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/COMPONENTS_EMPTY_DIR-ExpectedFiles.cmake deleted file mode 100644 index 62f2f9c..0000000 --- a/Tests/RunCMake/CPack/DEB/COMPONENTS_EMPTY_DIR-ExpectedFiles.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_1 "components_empty_dir-test_0.1.1-1_*.deb") -set(EXPECTED_FILE_CONTENT_1 "^.*/usr/${whitespaces_}.*/usr/empty/$") diff --git a/Tests/RunCMake/CPack/DEB/CUSTOM_NAMES-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/CUSTOM_NAMES-ExpectedFiles.cmake deleted file mode 100644 index 2acf45b..0000000 --- a/Tests/RunCMake/CPack/DEB/CUSTOM_NAMES-ExpectedFiles.cmake +++ /dev/null @@ -1,9 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "3") -set(EXPECTED_FILE_1 "custom_names-pkg_1_0.1.1-1_*.deb") -set(EXPECTED_FILE_CONTENT_1 "^.*/usr/foo${whitespaces_}.*/usr/foo/CMakeLists.txt$") -set(EXPECTED_FILE_2 "second*.deb") -set(EXPECTED_FILE_CONTENT_2 "^.*/usr/foo${whitespaces_}.*/usr/foo/CMakeLists.txt$") -set(EXPECTED_FILE_3 "pkg_3_abc.deb") -set(EXPECTED_FILE_CONTENT_3 "^.*/usr/foo${whitespaces_}.*/usr/foo/CMakeLists.txt$") diff --git a/Tests/RunCMake/CPack/DEB/CUSTOM_NAMES-specifics.cmake b/Tests/RunCMake/CPack/DEB/CUSTOM_NAMES-specifics.cmake deleted file mode 100644 index c64f161..0000000 --- a/Tests/RunCMake/CPack/DEB/CUSTOM_NAMES-specifics.cmake +++ /dev/null @@ -1,6 +0,0 @@ -set(CPACK_PACKAGE_CONTACT "someone") -set(CPACK_DEB_COMPONENT_INSTALL "ON") - -set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") -set(CPACK_DEBIAN_PKG_2_PACKAGE_NAME "second") -set(CPACK_DEBIAN_PKG_3_FILE_NAME "pkg_3_abc.deb") diff --git a/Tests/RunCMake/CPack/DEB/DEB_EXTRA-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/DEB_EXTRA-ExpectedFiles.cmake deleted file mode 100644 index 4531a34..0000000 --- a/Tests/RunCMake/CPack/DEB/DEB_EXTRA-ExpectedFiles.cmake +++ /dev/null @@ -1,9 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "3") -set(EXPECTED_FILE_1 "deb_extra-foo_0.1.1-1_*.deb") -set(EXPECTED_FILE_CONTENT_1 "^.*/usr/${whitespaces_}.*/usr/foo/${whitespaces_}.*/usr/foo/CMakeLists.txt$") -set(EXPECTED_FILE_2 "deb_extra-bar_0.1.1-1_*.deb") -set(EXPECTED_FILE_CONTENT_2 "^.*/usr/${whitespaces_}.*/usr/bar/${whitespaces_}.*/usr/bar/CMakeLists.txt$") -set(EXPECTED_FILE_3 "deb_extra-bas_0.1.1-1_*.deb") -set(EXPECTED_FILE_CONTENT_3 "^.*/usr/${whitespaces_}.*/usr/bas/${whitespaces_}.*/usr/bas/CMakeLists.txt$") diff --git a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-Prerequirements.cmake b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-Prerequirements.cmake deleted file mode 100644 index b98065a..0000000 --- a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-Prerequirements.cmake +++ /dev/null @@ -1,7 +0,0 @@ -function(get_test_prerequirements found_var) - find_program(READELF_EXECUTABLE NAMES readelf) - - if(READELF_EXECUTABLE) - set(${found_var} true PARENT_SCOPE) - endif() -endfunction() diff --git a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-Prerequirements.cmake b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-Prerequirements.cmake deleted file mode 100644 index b98065a..0000000 --- a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-Prerequirements.cmake +++ /dev/null @@ -1,7 +0,0 @@ -function(get_test_prerequirements found_var) - find_program(READELF_EXECUTABLE NAMES readelf) - - if(READELF_EXECUTABLE) - set(${found_var} true PARENT_SCOPE) - endif() -endfunction() diff --git a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake deleted file mode 100644 index a6f08fe..0000000 --- a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake +++ /dev/null @@ -1,14 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "5") -set(EXPECTED_FILE_1 "dependencies-0.1.1-*-applications.deb") -set(EXPECTED_FILE_CONTENT_1 "^.*/usr/foo${whitespaces_}.*/usr/foo/test_prog$") -set(EXPECTED_FILE_2 "dependencies-0.1.1-*-applications_auto.deb") -set(EXPECTED_FILE_CONTENT_2 "^.*/usr/foo_auto${whitespaces_}.*/usr/foo_auto/test_prog$") -set(EXPECTED_FILE_3 "dependencies-0.1.1-*-headers.deb") -set(EXPECTED_FILE_CONTENT_3 "^.*/usr/bar${whitespaces_}.*/usr/bar/CMakeLists.txt$") -set(EXPECTED_FILE_4 "dependencies-0.1.1-*-libs.deb") -# dynamic lib extension is .so on Linux and .dylib on Mac so we will use a wildcard .* for it -set(EXPECTED_FILE_CONTENT_4 "^.*/usr/bas${whitespaces_}.*/usr/bas/libtest_lib\\..*$") -set(EXPECTED_FILE_5 "dependencies-0.1.1-*-libs_auto.deb") -set(EXPECTED_FILE_CONTENT_5 "^.*/usr/bas_auto${whitespaces_}.*/usr/bas_auto/libtest_lib\\..*$") diff --git a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-VerifyResult.cmake b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-VerifyResult.cmake deleted file mode 100644 index ba39f2e..0000000 --- a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-VerifyResult.cmake +++ /dev/null @@ -1,34 +0,0 @@ -function(checkDependencies_ FILE REGEX) - set(whitespaces_ "[\t\n\r ]*") - - getPackageInfo("${FILE}" "FILE_INFO_") - if(NOT FILE_INFO_ MATCHES "${REGEX}") - message(FATAL_ERROR "Unexpected dependencies in '${FILE}'; file info: '${FILE_INFO_}'") - endif() -endfunction() - -foreach(dependency_type_ DEPENDS CONFLICTS ENHANCES BREAKS REPLACES RECOMMENDS SUGGESTS) - string(TOLOWER "${dependency_type_}" lower_dependency_type_) - string(SUBSTRING ${lower_dependency_type_} 1 -1 lower_dependency_type_tail_) - string(SUBSTRING ${dependency_type_} 0 1 dependency_type_head_) - set(dependency_type_name_ "${dependency_type_head_}${lower_dependency_type_tail_}") - - checkDependencies_("${FOUND_FILE_1}" ".*${dependency_type_name_}${whitespaces_}:${whitespaces_}${lower_dependency_type_}-application, ${lower_dependency_type_}-application-b.*") - checkDependencies_("${FOUND_FILE_2}" ".*${dependency_type_name_}${whitespaces_}:${whitespaces_}.*${lower_dependency_type_}-application, ${lower_dependency_type_}-application-b.*") - checkDependencies_("${FOUND_FILE_3}" ".*${dependency_type_name_}${whitespaces_}:${whitespaces_}${lower_dependency_type_}-headers.*") - checkDependencies_("${FOUND_FILE_4}" ".*${dependency_type_name_}${whitespaces_}:${whitespaces_}${lower_dependency_type_}-default, ${lower_dependency_type_}-default-b.*") - checkDependencies_("${FOUND_FILE_5}" ".*${dependency_type_name_}${whitespaces_}:${whitespaces_}${lower_dependency_type_}-default, ${lower_dependency_type_}-default-b.*") -endforeach() - -checkDependencies_("${FOUND_FILE_1}" ".*Provides${whitespaces_}:${whitespaces_}provided-default, provided-default-b") -checkDependencies_("${FOUND_FILE_2}" ".*Provides${whitespaces_}:${whitespaces_}provided-default, provided-default-b") -checkDependencies_("${FOUND_FILE_3}" ".*Provides${whitespaces_}:${whitespaces_}provided-default, provided-default-b") -checkDependencies_("${FOUND_FILE_4}" ".*Provides${whitespaces_}:${whitespaces_}provided-lib.*") -checkDependencies_("${FOUND_FILE_5}" ".*Provides${whitespaces_}:${whitespaces_}provided-lib_auto.*, provided-lib_auto-b.*") - -# PREDEPENDS -checkDependencies_("${FOUND_FILE_1}" ".*Pre-Depends${whitespaces_}:${whitespaces_}predepends-application, predepends-application-b.*") -checkDependencies_("${FOUND_FILE_2}" ".*Pre-Depends${whitespaces_}:${whitespaces_}.*predepends-application, predepends-application-b.*") -checkDependencies_("${FOUND_FILE_3}" ".*Pre-Depends${whitespaces_}:${whitespaces_}predepends-headers.*") -checkDependencies_("${FOUND_FILE_4}" ".*Pre-Depends${whitespaces_}:${whitespaces_}predepends-default, predepends-default-b.*") -checkDependencies_("${FOUND_FILE_5}" ".*Pre-Depends${whitespaces_}:${whitespaces_}predepends-default, predepends-default-b.*") diff --git a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-specifics.cmake b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-specifics.cmake deleted file mode 100644 index 5f82cc6..0000000 --- a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-specifics.cmake +++ /dev/null @@ -1,23 +0,0 @@ -set(CPACK_PACKAGE_CONTACT "someone") -set(CPACK_DEB_COMPONENT_INSTALL "ON") -#intentionaly commented out to test old file naming -#set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") - -# false by default -set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS FALSE) -# FIXME can not be tested as libraries first have to be part of a package in order -# to determine their dependencies and we can not be certain if there will be any -set(CPACK_DEBIAN_APPLICATIONS_AUTO_PACKAGE_SHLIBDEPS TRUE) - -foreach(dependency_type_ DEPENDS CONFLICTS PREDEPENDS ENHANCES BREAKS REPLACES RECOMMENDS SUGGESTS) - string(TOLOWER "${dependency_type_}" lower_dependency_type_) - - set(CPACK_DEBIAN_PACKAGE_${dependency_type_} "${lower_dependency_type_}-default, ${lower_dependency_type_}-default-b") - set(CPACK_DEBIAN_APPLICATIONS_PACKAGE_${dependency_type_} "${lower_dependency_type_}-application, ${lower_dependency_type_}-application-b") - set(CPACK_DEBIAN_APPLICATIONS_AUTO_PACKAGE_${dependency_type_} "${lower_dependency_type_}-application, ${lower_dependency_type_}-application-b") - set(CPACK_DEBIAN_HEADERS_PACKAGE_${dependency_type_} "${lower_dependency_type_}-headers") -endforeach() - -set(CPACK_DEBIAN_PACKAGE_PROVIDES "provided-default, provided-default-b") -set(CPACK_DEBIAN_LIBS_PACKAGE_PROVIDES "provided-lib") -set(CPACK_DEBIAN_LIBS_AUTO_PACKAGE_PROVIDES "provided-lib_auto, provided-lib_auto-b") diff --git a/Tests/RunCMake/CPack/DEB/EMPTY_DIR-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/EMPTY_DIR-ExpectedFiles.cmake deleted file mode 100644 index 6dc5906..0000000 --- a/Tests/RunCMake/CPack/DEB/EMPTY_DIR-ExpectedFiles.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_1 "empty_dir_0.1.1-1_*.deb") -set(EXPECTED_FILE_CONTENT_1 "^.*/usr/${whitespaces_}.*/usr/empty/$") diff --git a/Tests/RunCMake/CPack/DEB/EMPTY_DIR-specifics.cmake b/Tests/RunCMake/CPack/DEB/EMPTY_DIR-specifics.cmake deleted file mode 100644 index 4e9a2e7..0000000 --- a/Tests/RunCMake/CPack/DEB/EMPTY_DIR-specifics.cmake +++ /dev/null @@ -1,2 +0,0 @@ -set(CPACK_PACKAGE_CONTACT "someone") -set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") diff --git a/Tests/RunCMake/CPack/DEB/Helpers.cmake b/Tests/RunCMake/CPack/DEB/Helpers.cmake index 9b1be22..ad1b47b 100644 --- a/Tests/RunCMake/CPack/DEB/Helpers.cmake +++ b/Tests/RunCMake/CPack/DEB/Helpers.cmake @@ -9,6 +9,47 @@ function(getPackageContent FILE RESULT_VAR) set(${RESULT_VAR} "${package_content_}" PARENT_SCOPE) endfunction() +function(getPackageNameGlobexpr NAME COMPONENT VERSION REVISION FILE_NO RESULT_VAR) + if(COMPONENT) + set(COMPONENT "-${COMPONENT}") + endif() + + if(DEFINED EXPECTED_FILE_${FILE_NO}_FILENAME_GENERATOR_SPECIFIC_FORMAT) + set(GENERATOR_SPECIFIC_FORMAT "${EXPECTED_FILE_${FILE_NO}_FILENAME_GENERATOR_SPECIFIC_FORMAT}") + elseif(DEFINED EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT) + set(GENERATOR_SPECIFIC_FORMAT "${EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT}") + else() + set(GENERATOR_SPECIFIC_FORMAT FALSE) + endif() + + if(GENERATOR_SPECIFIC_FORMAT) + set(${RESULT_VAR} "${NAME}${COMPONENT}_${VERSION}-${REVISION}_*.deb" PARENT_SCOPE) + else() + set(${RESULT_VAR} "${NAME}-${VERSION}-*${COMPONENT}.deb" PARENT_SCOPE) + endif() +endfunction() + +function(getPackageContentList FILE RESULT_VAR) + execute_process(COMMAND ${DPKG_EXECUTABLE} -c "${FILE}" + OUTPUT_VARIABLE package_content_ + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + + unset(items_) + string(REPLACE "\n" ";" package_content_ "${package_content_}") + foreach(i_ IN LISTS package_content_) + string(REGEX REPLACE "^.* \.(/[^$]*)$" "\\1" result_ "${i_}") + string(REGEX REPLACE "/$" "" result_ "${result_}") + list(APPEND items_ "${result_}") + endforeach() + + set(${RESULT_VAR} "${items_}" PARENT_SCOPE) +endfunction() + +function(toExpectedContentList FILE_NO CONTENT_VAR) + # no need to do anything +endfunction() + function(getMissingShlibsErrorExtra FILE RESULT_VAR) execute_process(COMMAND ${DPKG_EXECUTABLE} -x "${FILE}" data_${PREFIX} ERROR_VARIABLE err_) @@ -43,8 +84,6 @@ function(getMissingShlibsErrorExtra FILE RESULT_VAR) string(APPEND error_extra "; errors \"${deb_install_files_errors}\"") endif() - find_program(READELF_EXECUTABLE NAMES readelf) - if(READELF_EXECUTABLE) string(APPEND error_extra "; readelf \"\n") diff --git a/Tests/RunCMake/CPack/DEB/LONG_FILENAMES-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/LONG_FILENAMES-ExpectedFiles.cmake deleted file mode 100644 index dd72cf7..0000000 --- a/Tests/RunCMake/CPack/DEB/LONG_FILENAMES-ExpectedFiles.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_1 "long_filenames_0.1.1-1_*.deb") -set(EXPECTED_FILE_CONTENT_1 "^.*/usr/${whitespaces_}.*/usr/foo/${whitespaces_}.*/usr/foo/llllllllll_oooooooooo_nnnnnnnnnn_gggggggggg_ffffffffff_iiiiiiiiii_llllllllll_eeeeeeeeee_nnnnnnnnnn_aaaaaaaaaa_mmmmmmmmmm_eeeeeeeeee.txt$") diff --git a/Tests/RunCMake/CPack/DEB/LONG_FILENAMES-Prerequirements.cmake b/Tests/RunCMake/CPack/DEB/LONG_FILENAMES-Prerequirements.cmake deleted file mode 100644 index 0c1d77e..0000000 --- a/Tests/RunCMake/CPack/DEB/LONG_FILENAMES-Prerequirements.cmake +++ /dev/null @@ -1,7 +0,0 @@ -function(get_test_prerequirements found_var) - find_program(FAKEROOT_EXECUTABLE NAMES fakeroot) - - if(FAKEROOT_EXECUTABLE) - set(${found_var} true PARENT_SCOPE) - endif() -endfunction() diff --git a/Tests/RunCMake/CPack/DEB/LONG_FILENAMES-specifics.cmake b/Tests/RunCMake/CPack/DEB/LONG_FILENAMES-specifics.cmake deleted file mode 100644 index 39a6be4..0000000 --- a/Tests/RunCMake/CPack/DEB/LONG_FILENAMES-specifics.cmake +++ /dev/null @@ -1,3 +0,0 @@ -set(CPACK_PACKAGE_CONTACT "someone") -set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") -set(CPACK_DEBIAN_ARCHIVE_TYPE "gnutar") diff --git a/Tests/RunCMake/CPack/DEB/MINIMAL-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/MINIMAL-ExpectedFiles.cmake deleted file mode 100644 index 648c866..0000000 --- a/Tests/RunCMake/CPack/DEB/MINIMAL-ExpectedFiles.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_1 "minimal_0.1.1-1_*.deb") -set(EXPECTED_FILE_CONTENT_1 "^.*/usr/${whitespaces_}.*/usr/foo/${whitespaces_}.*/usr/foo/CMakeLists.txt$") diff --git a/Tests/RunCMake/CPack/DEB/MINIMAL-specifics.cmake b/Tests/RunCMake/CPack/DEB/MINIMAL-specifics.cmake deleted file mode 100644 index 4e9a2e7..0000000 --- a/Tests/RunCMake/CPack/DEB/MINIMAL-specifics.cmake +++ /dev/null @@ -1,2 +0,0 @@ -set(CPACK_PACKAGE_CONTACT "someone") -set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") diff --git a/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-ExpectedFiles.cmake deleted file mode 100644 index 40f6730..0000000 --- a/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-ExpectedFiles.cmake +++ /dev/null @@ -1,9 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "3") -set(EXPECTED_FILE_1 "per_component-pkg_1_0.1.1-1_*.deb") -set(EXPECTED_FILE_CONTENT_1 "^.*/usr/foo${whitespaces_}.*/usr/foo/CMakeLists.txt$") -set(EXPECTED_FILE_2 "second_0.1.1-1_*.deb") -set(EXPECTED_FILE_CONTENT_2 "^.*/usr/foo${whitespaces_}.*/usr/foo/CMakeLists.txt$") -set(EXPECTED_FILE_3 "per_component-pkg_3_0.1.1-1_*.deb") -set(EXPECTED_FILE_CONTENT_3 "^.*/usr/foo${whitespaces_}.*/usr/foo/CMakeLists.txt$") diff --git a/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-VerifyResult.cmake b/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-VerifyResult.cmake deleted file mode 100644 index 55293be..0000000 --- a/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-VerifyResult.cmake +++ /dev/null @@ -1,18 +0,0 @@ -function(checkPackageInfo_ TYPE FILE REGEX) - set(whitespaces_ "[\t\n\r ]*") - - getPackageInfo("${FILE}" "FILE_INFO_") - if(NOT FILE_INFO_ MATCHES "${REGEX}") - message(FATAL_ERROR "Unexpected ${TYPE} in '${FILE}'; file info: '${FILE_INFO_}'") - endif() -endfunction() - -# check package name -checkPackageInfo_("name" "${FOUND_FILE_1}" ".*Package${whitespaces_}:${whitespaces_}per_component-pkg_1") -checkPackageInfo_("name" "${FOUND_FILE_2}" ".*Package${whitespaces_}:${whitespaces_}second") -checkPackageInfo_("name" "${FOUND_FILE_3}" ".*Package${whitespaces_}:${whitespaces_}per_component-pkg_3") - -# check package group -checkPackageInfo_("group" "${FOUND_FILE_1}" ".*Section${whitespaces_}:${whitespaces_}default") -checkPackageInfo_("group" "${FOUND_FILE_2}" ".*Section${whitespaces_}:${whitespaces_}second_group") -checkPackageInfo_("group" "${FOUND_FILE_3}" ".*Section${whitespaces_}:${whitespaces_}default") diff --git a/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-specifics.cmake b/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-specifics.cmake deleted file mode 100644 index 25bd2e7..0000000 --- a/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-specifics.cmake +++ /dev/null @@ -1,7 +0,0 @@ -set(CPACK_PACKAGE_CONTACT "someone") -set(CPACK_DEB_COMPONENT_INSTALL "ON") -set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") - -set(CPACK_DEBIAN_PACKAGE_SECTION "default") -set(CPACK_DEBIAN_PKG_2_PACKAGE_NAME "second") -set(CPACK_DEBIAN_PKG_2_PACKAGE_SECTION "second_group") diff --git a/Tests/RunCMake/CPack/DEB/Prerequirements.cmake b/Tests/RunCMake/CPack/DEB/Prerequirements.cmake index cb9a277..60d02e7 100644 --- a/Tests/RunCMake/CPack/DEB/Prerequirements.cmake +++ b/Tests/RunCMake/CPack/DEB/Prerequirements.cmake @@ -12,4 +12,11 @@ function(get_test_prerequirements found_var config_file) file(APPEND "${config_file}" "\nset(FAKEROOT_EXECUTABLE \"${FAKEROOT_EXECUTABLE}\")") endif() + + # optional tool for some tests + find_program(READELF_EXECUTABLE NAMES readelf) + if(READELF_EXECUTABLE) + file(APPEND "${config_file}" + "\nset(READELF_EXECUTABLE \"${READELF_EXECUTABLE}\")") + endif() endfunction() diff --git a/Tests/RunCMake/CPack/DEB/COMPONENTS_EMPTY_DIR-specifics.cmake b/Tests/RunCMake/CPack/DEB/packaging_COMPONENT_default.cmake index 4b4ac8d..4219b0c 100644 --- a/Tests/RunCMake/CPack/DEB/COMPONENTS_EMPTY_DIR-specifics.cmake +++ b/Tests/RunCMake/CPack/DEB/packaging_COMPONENT_default.cmake @@ -1,3 +1,2 @@ -set(CPACK_PACKAGE_CONTACT "someone") set(CPACK_DEB_COMPONENT_INSTALL "ON") -set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") +set(CPACK_PACKAGE_CONTACT "someone") diff --git a/Tests/RunCMake/CPack/DEB/packaging_MONOLITHIC_default.cmake b/Tests/RunCMake/CPack/DEB/packaging_MONOLITHIC_default.cmake new file mode 100644 index 0000000..8821ab9 --- /dev/null +++ b/Tests/RunCMake/CPack/DEB/packaging_MONOLITHIC_default.cmake @@ -0,0 +1 @@ +set(CPACK_PACKAGE_CONTACT "someone") diff --git a/Tests/RunCMake/CPack/DEPENDENCIES.cmake b/Tests/RunCMake/CPack/DEPENDENCIES.cmake deleted file mode 100644 index 4f6d65f..0000000 --- a/Tests/RunCMake/CPack/DEPENDENCIES.cmake +++ /dev/null @@ -1,20 +0,0 @@ -set(CMAKE_BUILD_WITH_INSTALL_RPATH 1) - -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.hpp" - "int test_lib();\n") -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp" - "#include \"test_lib.hpp\"\nint test_lib() {return 0;}\n") -add_library(test_lib SHARED "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp") - -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp" - "#include \"test_lib.hpp\"\nint main() {return test_lib();}\n") -add_executable(test_prog "${CMAKE_CURRENT_BINARY_DIR}/main.cpp") -target_link_libraries(test_prog test_lib) - -install(TARGETS test_prog DESTINATION foo COMPONENT applications) -install(TARGETS test_prog DESTINATION foo_auto COMPONENT applications_auto) -install(FILES CMakeLists.txt DESTINATION bar COMPONENT headers) -install(TARGETS test_lib DESTINATION bas COMPONENT libs) -install(TARGETS test_lib DESTINATION bas_auto COMPONENT libs_auto) - -set(CPACK_PACKAGE_NAME "dependencies") diff --git a/Tests/RunCMake/CPack/EMPTY_DIR.cmake b/Tests/RunCMake/CPack/EMPTY_DIR.cmake deleted file mode 100644 index 023ba17..0000000 --- a/Tests/RunCMake/CPack/EMPTY_DIR.cmake +++ /dev/null @@ -1,4 +0,0 @@ -install(DIRECTORY DESTINATION empty - COMPONENT test) - -set(CPACK_PACKAGE_NAME "empty_dir") diff --git a/Tests/RunCMake/CPack/PER_COMPONENT_FIELDS.cmake b/Tests/RunCMake/CPack/PER_COMPONENT_FIELDS.cmake deleted file mode 100644 index bb42cf4..0000000 --- a/Tests/RunCMake/CPack/PER_COMPONENT_FIELDS.cmake +++ /dev/null @@ -1,5 +0,0 @@ -install(FILES CMakeLists.txt DESTINATION foo COMPONENT pkg_1) -install(FILES CMakeLists.txt DESTINATION foo COMPONENT pkg_2) -install(FILES CMakeLists.txt DESTINATION foo COMPONENT pkg_3) - -set(CPACK_PACKAGE_NAME "per_component") diff --git a/Tests/RunCMake/CPack/README.txt b/Tests/RunCMake/CPack/README.txt index 5c86880..f51d254 100644 --- a/Tests/RunCMake/CPack/README.txt +++ b/Tests/RunCMake/CPack/README.txt @@ -1,41 +1,75 @@ RunCMake.CPack is a test module that is intended for testing of package generators that can be validated from command line. -TODO: all tests should cover all packaging types (single package, grouped and - component packaging) - ------------- Adding a test ------------- -CPack test root directory: 'Tests/RunCMake/CPack'. +CPack test root directory: 'Tests/RunCMake/CPack/tests'. All phases are executed separately for each generator that is bound to a test. Tests for each generator are subtests of test 'RunCMake.CPack_<generator_name>'. Each test must also be added to 'RunCMakeTest.cmake' script located in CPack test root directory. + Line that adds a test is: -run_cpack_test(<test_name> "<generator_name>") +run_cpack_test(<test_name> "<generator_name_list>" <compile_stage> + "<packaging_type_list>") + +<generator_name_list> may be one generator e.g. "RPM" or multiple e.g. "RPM;DEB" +and will be run for all listed generators. In test and verification scripts +current generator can be accessed through GENERATOR_TYPE variable. + +<compile_stage> is a boolean variable that enables or disables compile stage - +most tests don't require compilation as a non binary file can be used for +package content but sometimes an executable or a library has to be created +before the packaging stage. -<generator_name> may be one generator e.g. "RPM" or multiple e.g. "RPM;DEB" and -will be run for all listed generators. +<packaging_type_list> can be a list of one or more packaging types: MONOLITHIC, +COMPONENT or GROUP - each type sets per generator default variables which can +be overwritten in the test if needed +(see <generator_type>/packaging_<packaging_type>_default.cmake for the variables +that are set by default for each packaging type). +Alternatively CUSTOM value can be set which means that default values will not +be set and that values will be set manually in the test itself. + +Alternatively a test with subtests can be added: +run_cpack_test_subtests(<test_name> "<subtests_list>" "<generator_name_list>" + <compile_stage> "<packaging_type_list>") + +<subtests_list> is the only new parameter and it is a list of names that will +be used for subtests. In test and verification scripts subtest name can be +accessed through RunCMake_SUBTEST_SUFFIX variable. + +Also source package tests can be added: +run_cpack_source_test(<test_name> "<generator_name_list>" true) Test consists of - test prerequirements phase (optional) - CMake execution phase +- build phase (optional and not available for source package tests) - CPack execution phase - verification of generated files +The phases are executed once per specified generator, packaging type and subtest +combinatiion. + test prerequirements phase (optional): -------------------------------------- In some cases individual tests for certain generator need additional prerequirements met. -In such cases '<generator_name>/<test_name>-Prerequirements.cmake' file -containing 'function(get_test_prerequirements found_var)' should be created. -Function should return true if all prerequirements are met. +In such cases '<test_name>/<generator_name>-Prerequirements.cmake' file +containing 'function(get_test_prerequirements found_var config_file)' should be +created. Function should return true in found_var if all prerequirements are +met. config_file variable contains the location of config file generated by the +generator so that this function can check if prerequired variable is set in the +file. +NOTE: All required programs should be searched for in generator prerequirements +function and only checked for the variable in configure file in per test +function. If prerequirements are not met test will be skipped outputting '<test_name> - SKIPPED' string. Note that this doesn't fail the entire test @@ -48,15 +82,21 @@ TODO: skipped tests should provide expected error string so test should fail CMake execution phase: ---------------------- -To add a new CPack test we first create a <test_name>.cmake script that contains -CMake commands that should be used as a preparation script for generation of -different types of packages. This script is placed into CPack test root -directory even if it will be used for only one of the generators. +To add a new CPack test we first create a '<test_name>/test.cmake' script that +contains CMake commands that should be used as a preparation script for +generation of different types of packages. This script is placed into CPack +test root directory. If test will be used for multiple generators but some of them require some -generator specific commands then those commands should be added to a separate -file that should be located in '<generator_name>/<test_name>-specifics.cmake' -in CPack test root directory. +generator specific commands then those commands should be added to 'test.cmake' +script wrapped with 'if(GENERATOR_TYPE STREQUAL <name_of_the_generator>)'. + +build phase (optional and not available for source package tests) +----------------------------------------------------------------- + +This phase only runs make command. + +NOTE: By default all tests have CMAKE_BUILD_TYPE variable set to Debug. CPack execution phase: ---------------------- @@ -64,6 +104,8 @@ CPack execution phase: Only executes CPack for content that was generated during CMake execution phase. +NOTE: By default CPACK_PACKAGE_NAME variable is set to lower case test name. + Verification of generated files: -------------------------------- @@ -76,24 +118,49 @@ contain expected files. Mandatory verification phase also checks that no other unexpected package files were generated (this is executed even if EXPECTED_FILES_COUNT contains 0 in order to verify that no files were generated). -CMake script '<generator_name>/<test_name>-ExpectedFiles.cmake' is required by +CMake script '<test_name>/ExpectedFiles.cmake' is required by this step and must contain - EXPECTED_FILES_COUNT variable that contains the number of expected files that will be generated (0 or more) + - EXPECTED_FILE_<file_number_starting_with_1> that contains globing expression that uniquely defines expected file name (will be used to find expected file) - and should be present once for each expected file + and should be present once for each expected file. + NOTE: This variable should be used only as last resort as it sets generator + specific globbing expression. Each generator can recreate file name from + parts that are already populated by default but can always be + overwritten if needed: + - EXPECTED_FILE_<file_number_starting_with_1>_NAME is the name component of + the file (by default it is set to package name that is same as test name + in lowercase) + - EXPECTED_FILE_<file_number_starting_with_1>_VERSION is the version of the + package (by default it is set to '0.1.1') + - EXPECTED_FILE_<file_number_starting_with_1>_REVISION is the revision of the + package (by default it is set to '1') + - EXPECTED_FILE_CONTENT_<file_number_starting_with_1> that contains regular expression of files that should be present in generated file and should be present once for each expected file + NOTE: This variable should be used only as last resort as it sets generator + specific regular expression. + EXPECTED_FILE_CONTENT_<file_number_starting_with_1>_LIST should be + prefered as it requires a list of expected files and directories that + is later changed automatically depending on the generator so expected + package content can be written only once per test for all generators. Optional verification phase is generator specific and is optionaly executed. -This phase is executed if '<generator_name>/<test_name>-VerifyResult.cmake' -script exists. -In case that the script doesn't exist VerifyResult.cmake script automatically -prints out standard output and standard error from CPack execution phase that -is compared with '<generator_name>/<test_name>-stdout.txt' regular expression -and '<generator_name>/<test_name>-stderr.txt' regular expresson respectively. +This phase is executed if '<test_name>/VerifyResult.cmake' script exists. + +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. + 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 + file is used if present. ---------------------- Adding a new generator @@ -101,13 +168,44 @@ Adding a new generator To add a new generator we must - add new generator directory (e.g. RPM for RPM generator) to CPack test root - directory that contains 'Helpers.cmake' script. In this script a function - named 'getPackageContent' must exist. This function should list files that - are contained in a package. Function should accept two parameters - + FILE variable that will contain path to file for which the content should be - listed - + RESULT_VAR that will tell the function which variable in parent scope should - contain the result (list of files inside package file) + directory that contains 'Helpers.cmake' script. + - In this script some functions must exist: + - getPackageContent: This function should list files that are contained in + a package. + Function parameters: + + FILE variable that will contain path to file for which the content + should be listed + + RESULT_VAR that will tell the function which variable in parent scope + should contain the result (list of files inside package file) + - getPackageNameGlobexpr: This function should generate package name + globbing expression. + Function parameters: + + NAME that will contain the expected package name + + COMPONENT that will contain the expected package component + + VERSION that will contain the expected package version + + REVISION that will contain the expected package revision number + + FILE_NO that will contain the file number for which the globbing + expression is generated + + RESULT_VAR that will tell the function which variable in parent scope + should contain the result (file name globbing expression) + - getPackageContentList: This function should return a list of files and + directories that are in the provided package. + Function parameters: + + FILE that will contain the package file for which the package content + should be returned. + + RESULT_VAR that will tell the function which variable in parent scope + should contain the result (list of pacakge content) + - toExpectedContentList: This function should convert an expected package + content list into one that is expected for the + generator (e.g. rpm packages have install/relocate + path prefixes which aren't part of the package so + those paths have to be removed from the expected + content list). + Function parameters: + + FILE_NO that will contain the file number for which the conversion + should be performed + + CONTENT_VAR that will contain the input list and is also the variable + in parent scope which should contain the result (converted content list) - add 'Prerequirements.cmake' script to generator directory. In this script a function named 'get_test_prerequirements' must exist. This function should set a variable in parent scope (name of the variable is the first parameter) @@ -119,3 +217,9 @@ To add a new generator we must - add tests the same way as described above - add generator to 'add_RunCMake_test_group' function call that is located in RunCMake CMakeLists.txt file +- if needed add 'packaging_<packaging_type>_default.cmake' scripts that define + default variables that will be set for each packaging type (MONOLITHIC, + COMPONENT and GROUP) +- 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. diff --git a/Tests/RunCMake/CPack/RPM/COMPONENTS_EMPTY_DIR-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/COMPONENTS_EMPTY_DIR-ExpectedFiles.cmake deleted file mode 100644 index d396276..0000000 --- a/Tests/RunCMake/CPack/RPM/COMPONENTS_EMPTY_DIR-ExpectedFiles.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_1 "components_empty_dir*.rpm") -set(EXPECTED_FILE_CONTENT_1 "^/usr/empty$") diff --git a/Tests/RunCMake/CPack/RPM/COMPONENTS_EMPTY_DIR-stderr.txt b/Tests/RunCMake/CPack/RPM/COMPONENTS_EMPTY_DIR-stderr.txt deleted file mode 100644 index 6ddca12..0000000 --- a/Tests/RunCMake/CPack/RPM/COMPONENTS_EMPTY_DIR-stderr.txt +++ /dev/null @@ -1 +0,0 @@ -^CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/COMPONENTS_EMPTY_DIR-build/_CPack_Packages/.*/RPM/SPECS/components_empty_dir.spec$ diff --git a/Tests/RunCMake/CPack/RPM/CUSTOM_NAMES-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/CUSTOM_NAMES-ExpectedFiles.cmake deleted file mode 100644 index 780e57e..0000000 --- a/Tests/RunCMake/CPack/RPM/CUSTOM_NAMES-ExpectedFiles.cmake +++ /dev/null @@ -1,9 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "3") -set(EXPECTED_FILE_1 "custom_names-pkg_1*.rpm") -set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/CMakeLists.txt$") -set(EXPECTED_FILE_2 "second*.rpm") -set(EXPECTED_FILE_CONTENT_2 "^/usr/foo${whitespaces_}/usr/foo/CMakeLists.txt$") -set(EXPECTED_FILE_3 "pkg_3_abc.rpm") -set(EXPECTED_FILE_CONTENT_3 "^/usr/foo${whitespaces_}/usr/foo/CMakeLists.txt$") diff --git a/Tests/RunCMake/CPack/RPM/CUSTOM_NAMES-specifics.cmake b/Tests/RunCMake/CPack/RPM/CUSTOM_NAMES-specifics.cmake deleted file mode 100644 index 575aa01..0000000 --- a/Tests/RunCMake/CPack/RPM/CUSTOM_NAMES-specifics.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(CPACK_RPM_COMPONENT_INSTALL "ON") - -set(CPACK_RPM_FILE_NAME "RPM-DEFAULT") -set(CPACK_RPM_PKG_2_PACKAGE_NAME "second") -set(CPACK_RPM_PKG_3_FILE_NAME "pkg_3_abc.rpm") diff --git a/Tests/RunCMake/CPack/RPM/CUSTOM_NAMES-stderr.txt b/Tests/RunCMake/CPack/RPM/CUSTOM_NAMES-stderr.txt deleted file mode 100644 index 9bfba7e..0000000 --- a/Tests/RunCMake/CPack/RPM/CUSTOM_NAMES-stderr.txt +++ /dev/null @@ -1,3 +0,0 @@ -^CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/CUSTOM_NAMES-build/_CPack_Packages/.*/RPM/SPECS/custom_names-pkg_1.spec -CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/CUSTOM_NAMES-build/_CPack_Packages/.*/RPM/SPECS/second.spec -CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/CUSTOM_NAMES-build/_CPack_Packages/.*/RPM/SPECS/custom_names-pkg_3.spec$ diff --git a/Tests/RunCMake/CPack/RPM/DEBUGINFO-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/DEBUGINFO-ExpectedFiles.cmake deleted file mode 100644 index a583e32..0000000 --- a/Tests/RunCMake/CPack/RPM/DEBUGINFO-ExpectedFiles.cmake +++ /dev/null @@ -1,14 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "5") -set(EXPECTED_FILE_1 "debuginfo-applications-0*.rpm") -set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/test_prog$") -set(EXPECTED_FILE_2 "debuginfo*-headers.rpm") -set(EXPECTED_FILE_CONTENT_2 "^/usr/bar${whitespaces_}/usr/bar/CMakeLists.txt$") -set(EXPECTED_FILE_3 "debuginfo*-libs.rpm") -set(EXPECTED_FILE_CONTENT_3 "^/usr/bas${whitespaces_}/usr/bas/libtest_lib.so$") - -set(EXPECTED_FILE_4 "debuginfo-applications-debuginfo*.rpm") -set(EXPECTED_FILE_CONTENT_4 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp.*") -set(EXPECTED_FILE_5 "debuginfo-libs-debuginfo*.rpm") -set(EXPECTED_FILE_CONTENT_5 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/test_lib.cpp.*") diff --git a/Tests/RunCMake/CPack/RPM/DEBUGINFO-stderr.txt b/Tests/RunCMake/CPack/RPM/DEBUGINFO-stderr.txt deleted file mode 100644 index 557ef3d..0000000 --- a/Tests/RunCMake/CPack/RPM/DEBUGINFO-stderr.txt +++ /dev/null @@ -1,3 +0,0 @@ -^CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/DEBUGINFO-build/_CPack_Packages/.*/RPM/SPECS/debuginfo-applications.spec -CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/DEBUGINFO-build/_CPack_Packages/.*/RPM/SPECS/debuginfo-headers.spec -CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/DEBUGINFO-build/_CPack_Packages/.*/RPM/SPECS/debuginfo-libs.spec$ diff --git a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-ExpectedFiles.cmake deleted file mode 100644 index cf85dab..0000000 --- a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-ExpectedFiles.cmake +++ /dev/null @@ -1,13 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "5") -set(EXPECTED_FILE_1 "dependencies*-applications.rpm") -set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/test_prog$") -set(EXPECTED_FILE_2 "dependencies*-applications_auto.rpm") -set(EXPECTED_FILE_CONTENT_2 "^/usr/foo_auto${whitespaces_}/usr/foo_auto/test_prog$") -set(EXPECTED_FILE_3 "dependencies*-headers.rpm") -set(EXPECTED_FILE_CONTENT_3 "^/usr/bar${whitespaces_}/usr/bar/CMakeLists.txt$") -set(EXPECTED_FILE_4 "dependencies*-libs.rpm") -set(EXPECTED_FILE_CONTENT_4 "^/usr/bas${whitespaces_}/usr/bas/libtest_lib.so$") -set(EXPECTED_FILE_5 "dependencies*-libs_auto.rpm") -set(EXPECTED_FILE_CONTENT_5 "^/usr/bas_auto${whitespaces_}/usr/bas_auto/libtest_lib.so$") diff --git a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-VerifyResult.cmake b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-VerifyResult.cmake deleted file mode 100644 index fec8889..0000000 --- a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-VerifyResult.cmake +++ /dev/null @@ -1,45 +0,0 @@ -function(checkDependencies_ FILE TYPE COMPARE_LIST) - set(whitespaces_ "[\t\n\r ]*") - - execute_process(COMMAND ${RPM_EXECUTABLE} -qp --${TYPE} ${FILE} - WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" - OUTPUT_VARIABLE FILE_DEPENDENCIES_ - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - - string(REPLACE "\n" ";" FILE_DEPENDENCIES_LIST_ "${FILE_DEPENDENCIES_}") - - foreach(COMPARE_REGEX_ IN LISTS COMPARE_LIST) - unset(FOUND_) - - foreach(COMPARE_ IN LISTS FILE_DEPENDENCIES_LIST_) - if(COMPARE_ MATCHES "${COMPARE_REGEX_}") - set(FOUND_ true) - break() - endif() - endforeach() - - if(NOT FOUND_) - message(FATAL_ERROR "Missing dependencies in '${FILE}'; check type: '${TYPE}'; file info: '${FILE_DEPENDENCIES_}'; missing: '${COMPARE_REGEX_}'") - endif() - endforeach() -endfunction() - -# TODO add tests for what should not be present in lists -checkDependencies_("${FOUND_FILE_1}" "requires" "depend-application;depend-application-b") -checkDependencies_("${FOUND_FILE_2}" "requires" "depend-application;depend-application-b;libtest_lib\\.so.*") -checkDependencies_("${FOUND_FILE_3}" "requires" "depend-headers") -checkDependencies_("${FOUND_FILE_4}" "requires" "depend-default;depend-default-b") -checkDependencies_("${FOUND_FILE_5}" "requires" "depend-default;depend-default-b") - -checkDependencies_("${FOUND_FILE_1}" "conflicts" "conflict-application;conflict-application-b") -checkDependencies_("${FOUND_FILE_2}" "conflicts" "conflict-application;conflict-application-b") -checkDependencies_("${FOUND_FILE_3}" "conflicts" "conflict-headers") -checkDependencies_("${FOUND_FILE_4}" "conflicts" "conflict-default;conflict-default-b") -checkDependencies_("${FOUND_FILE_5}" "conflicts" "conflict-default;conflict-default-b") - -checkDependencies_("${FOUND_FILE_1}" "provides" "provided-default;provided-default-b") -checkDependencies_("${FOUND_FILE_2}" "provides" "provided-default;provided-default-b") -checkDependencies_("${FOUND_FILE_3}" "provides" "provided-default;provided-default-b") -checkDependencies_("${FOUND_FILE_4}" "provides" "provided-lib") -checkDependencies_("${FOUND_FILE_5}" "provides" "provided-lib_auto;provided-lib_auto-b") diff --git a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-specifics.cmake b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-specifics.cmake deleted file mode 100644 index 8b7fb1e..0000000 --- a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-specifics.cmake +++ /dev/null @@ -1,22 +0,0 @@ -set(CPACK_RPM_COMPONENT_INSTALL "ON") - -# FIXME auto autoprov is not tested at the moment as Ubuntu 15.04 rpmbuild -# does not use them correctly: https://bugs.launchpad.net/rpm/+bug/1475755 -set(CPACK_RPM_PACKAGE_AUTOREQ "no") -set(CPACK_RPM_PACKAGE_AUTOPROV "no") -set(CPACK_RPM_APPLICATIONS_AUTO_PACKAGE_AUTOREQPROV "yes") -set(CPACK_RPM_LIBS_AUTO_PACKAGE_AUTOREQPROV "yes") - -set(CPACK_RPM_PACKAGE_REQUIRES "depend-default, depend-default-b") -set(CPACK_RPM_APPLICATIONS_PACKAGE_REQUIRES "depend-application, depend-application-b") -set(CPACK_RPM_APPLICATIONS_AUTO_PACKAGE_REQUIRES "depend-application, depend-application-b") -set(CPACK_RPM_HEADERS_PACKAGE_REQUIRES "depend-headers") - -set(CPACK_RPM_PACKAGE_CONFLICTS "conflict-default, conflict-default-b") -set(CPACK_RPM_APPLICATIONS_PACKAGE_CONFLICTS "conflict-application, conflict-application-b") -set(CPACK_RPM_APPLICATIONS_AUTO_PACKAGE_CONFLICTS "conflict-application, conflict-application-b") -set(CPACK_RPM_HEADERS_PACKAGE_CONFLICTS "conflict-headers") - -set(CPACK_RPM_PACKAGE_PROVIDES "provided-default, provided-default-b") -set(CPACK_RPM_LIBS_PACKAGE_PROVIDES "provided-lib") -set(CPACK_RPM_LIBS_AUTO_PACKAGE_PROVIDES "provided-lib_auto, provided-lib_auto-b") diff --git a/Tests/RunCMake/CPack/RPM/EMPTY_DIR-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/EMPTY_DIR-ExpectedFiles.cmake deleted file mode 100644 index 0c2977f..0000000 --- a/Tests/RunCMake/CPack/RPM/EMPTY_DIR-ExpectedFiles.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_1 "empty_dir*.rpm") -set(EXPECTED_FILE_CONTENT_1 "^/usr/empty$") diff --git a/Tests/RunCMake/CPack/RPM/EMPTY_DIR-stderr.txt b/Tests/RunCMake/CPack/RPM/EMPTY_DIR-stderr.txt deleted file mode 100644 index 1777aa0..0000000 --- a/Tests/RunCMake/CPack/RPM/EMPTY_DIR-stderr.txt +++ /dev/null @@ -1 +0,0 @@ -^CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/EMPTY_DIR-build/_CPack_Packages/.*/RPM/SPECS/empty_dir.spec$ diff --git a/Tests/RunCMake/CPack/RPM/Helpers.cmake b/Tests/RunCMake/CPack/RPM/Helpers.cmake index ba77a4a..bbc358c8 100644 --- a/Tests/RunCMake/CPack/RPM/Helpers.cmake +++ b/Tests/RunCMake/CPack/RPM/Helpers.cmake @@ -9,6 +9,59 @@ function(getPackageContent FILE RESULT_VAR) set(${RESULT_VAR} "${package_content_}" PARENT_SCOPE) endfunction() +function(getPackageNameGlobexpr NAME COMPONENT VERSION REVISION FILE_NO RESULT_VAR) + if(COMPONENT) + set(COMPONENT "-${COMPONENT}") + endif() + + if(DEFINED EXPECTED_FILE_${FILE_NO}_FILENAME_GENERATOR_SPECIFIC_FORMAT) + set(GENERATOR_SPECIFIC_FORMAT "${EXPECTED_FILE_${FILE_NO}_FILENAME_GENERATOR_SPECIFIC_FORMAT}") + elseif(DEFINED EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT) + set(GENERATOR_SPECIFIC_FORMAT "${EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT}") + else() + set(GENERATOR_SPECIFIC_FORMAT FALSE) + endif() + + if(GENERATOR_SPECIFIC_FORMAT) + set(${RESULT_VAR} "${NAME}${COMPONENT}-${VERSION}-${REVISION}.*.rpm" PARENT_SCOPE) + else() + set(${RESULT_VAR} "${NAME}-${VERSION}-*${COMPONENT}.rpm" PARENT_SCOPE) + endif() +endfunction() + +function(getPackageContentList FILE RESULT_VAR) + execute_process(COMMAND ${RPM_EXECUTABLE} -pql ${FILE} + OUTPUT_VARIABLE package_content_ + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + string(REGEX REPLACE "\n" ";" package_content_ "${package_content_}") + + set(${RESULT_VAR} "${package_content_}" PARENT_SCOPE) +endfunction() + +function(toExpectedContentList FILE_NO CONTENT_VAR) + if(NOT DEFINED TEST_INSTALL_PREFIX_PATHS) + set(TEST_INSTALL_PREFIX_PATHS "/usr") + endif() + + unset(filtered_) + foreach(part_ IN LISTS ${CONTENT_VAR}) + unset(dont_add_) + foreach(for_removal_ IN LISTS TEST_INSTALL_PREFIX_PATHS) + if(part_ STREQUAL for_removal_) + set(dont_add_ TRUE) + break() + endif() + endforeach() + + if(NOT dont_add_) + list(APPEND filtered_ "${part_}") + endif() + endforeach() + + set(${CONTENT_VAR} "${filtered_}" PARENT_SCOPE) +endfunction() + function(getPackageInfo FILE RESULT_VAR) execute_process(COMMAND ${RPM_EXECUTABLE} -pqi ${FILE} OUTPUT_VARIABLE info_content diff --git a/Tests/RunCMake/CPack/RPM/INSTALL_SCRIPTS-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/INSTALL_SCRIPTS-ExpectedFiles.cmake deleted file mode 100644 index 033a45d..0000000 --- a/Tests/RunCMake/CPack/RPM/INSTALL_SCRIPTS-ExpectedFiles.cmake +++ /dev/null @@ -1,7 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "2") -set(EXPECTED_FILE_1 "install_scripts*-foo.rpm") -set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/CMakeLists.txt$") -set(EXPECTED_FILE_2 "install_scripts*-bar.rpm") -set(EXPECTED_FILE_CONTENT_2 "^/usr/bar${whitespaces_}/usr/bar/CMakeLists.txt$") diff --git a/Tests/RunCMake/CPack/RPM/INSTALL_SCRIPTS-specifics.cmake b/Tests/RunCMake/CPack/RPM/INSTALL_SCRIPTS-specifics.cmake deleted file mode 100644 index 4eb53c3..0000000 --- a/Tests/RunCMake/CPack/RPM/INSTALL_SCRIPTS-specifics.cmake +++ /dev/null @@ -1,19 +0,0 @@ -set(CPACK_RPM_COMPONENT_INSTALL "ON") - -set(CPACK_RPM_PRE_INSTALL_SCRIPT_FILE - "${CMAKE_CURRENT_BINARY_DIR}/pre_install.sh") -set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE - "${CMAKE_CURRENT_BINARY_DIR}/post_install.sh") -set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE - "${CMAKE_CURRENT_BINARY_DIR}/pre_uninstall.sh") -set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE - "${CMAKE_CURRENT_BINARY_DIR}/post_uninstall.sh") - -set(CPACK_RPM_foo_PRE_INSTALL_SCRIPT_FILE - "${CMAKE_CURRENT_BINARY_DIR}/pre_install_foo.sh") -set(CPACK_RPM_foo_POST_INSTALL_SCRIPT_FILE - "${CMAKE_CURRENT_BINARY_DIR}/post_install_foo.sh") -set(CPACK_RPM_foo_PRE_UNINSTALL_SCRIPT_FILE - "${CMAKE_CURRENT_BINARY_DIR}/pre_uninstall_foo.sh") -set(CPACK_RPM_foo_POST_UNINSTALL_SCRIPT_FILE - "${CMAKE_CURRENT_BINARY_DIR}/post_uninstall_foo.sh") diff --git a/Tests/RunCMake/CPack/RPM/MAIN_COMPONENT-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/MAIN_COMPONENT-ExpectedFiles.cmake deleted file mode 100644 index 69603dd..0000000 --- a/Tests/RunCMake/CPack/RPM/MAIN_COMPONENT-ExpectedFiles.cmake +++ /dev/null @@ -1,13 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "0") - -if(NOT RunCMake_SUBTEST_SUFFIX STREQUAL "invalid") - set(EXPECTED_FILES_COUNT "3") - set(EXPECTED_FILE_1 "main_component-0.1.1-1.*.rpm") - set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/CMakeLists.txt$") - set(EXPECTED_FILE_2 "main_component*-headers.rpm") - set(EXPECTED_FILE_CONTENT_2 "^/usr/bar${whitespaces_}/usr/bar/CMakeLists.txt$") - set(EXPECTED_FILE_3 "main_component*-libs.rpm") - set(EXPECTED_FILE_CONTENT_3 "^/usr/bas${whitespaces_}/usr/bas/CMakeLists.txt$") -endif() diff --git a/Tests/RunCMake/CPack/RPM/MAIN_COMPONENT-found-stderr.txt b/Tests/RunCMake/CPack/RPM/MAIN_COMPONENT-found-stderr.txt deleted file mode 100644 index dff163d..0000000 --- a/Tests/RunCMake/CPack/RPM/MAIN_COMPONENT-found-stderr.txt +++ /dev/null @@ -1,3 +0,0 @@ -^CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/MAIN_COMPONENT-build-found-subtest/_CPack_Packages/.*/RPM/SPECS/main_component-headers.spec -CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/MAIN_COMPONENT-build-found-subtest/_CPack_Packages/.*/RPM/SPECS/main_component-libs.spec -CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/MAIN_COMPONENT-build-found-subtest/_CPack_Packages/.*/RPM/SPECS/main_component.spec$ diff --git a/Tests/RunCMake/CPack/RPM/MINIMAL-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/MINIMAL-ExpectedFiles.cmake deleted file mode 100644 index 800b78e..0000000 --- a/Tests/RunCMake/CPack/RPM/MINIMAL-ExpectedFiles.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_1 "minimal*.rpm") -set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/CMakeLists.txt$") diff --git a/Tests/RunCMake/CPack/RPM/MINIMAL-stderr.txt b/Tests/RunCMake/CPack/RPM/MINIMAL-stderr.txt deleted file mode 100644 index 7c5fb46..0000000 --- a/Tests/RunCMake/CPack/RPM/MINIMAL-stderr.txt +++ /dev/null @@ -1 +0,0 @@ -^CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/MINIMAL-build/_CPack_Packages/.*/RPM/SPECS/minimal.spec$ diff --git a/Tests/RunCMake/CPack/RPM/PARTIALLY_RELOCATABLE_WARNING-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/PARTIALLY_RELOCATABLE_WARNING-ExpectedFiles.cmake deleted file mode 100644 index 4e01f7b..0000000 --- a/Tests/RunCMake/CPack/RPM/PARTIALLY_RELOCATABLE_WARNING-ExpectedFiles.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_1 "PARTIALLY_RELOCATABLE_WARNING-0.1.1-*.rpm") -set(EXPECTED_FILE_CONTENT_1 "^/not_relocatable${whitespaces_}/not_relocatable/CMakeLists.txt${whitespaces_}/opt$") diff --git a/Tests/RunCMake/CPack/RPM/PER_COMPONENT_FIELDS-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/PER_COMPONENT_FIELDS-ExpectedFiles.cmake deleted file mode 100644 index 3d28d41..0000000 --- a/Tests/RunCMake/CPack/RPM/PER_COMPONENT_FIELDS-ExpectedFiles.cmake +++ /dev/null @@ -1,9 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "3") -set(EXPECTED_FILE_1 "per_component*-pkg_1.rpm") -set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/CMakeLists.txt$") -set(EXPECTED_FILE_2 "per_component*-pkg_2.rpm") -set(EXPECTED_FILE_CONTENT_2 "^/usr/foo${whitespaces_}/usr/foo/CMakeLists.txt$") -set(EXPECTED_FILE_3 "per_component*-pkg_3.rpm") -set(EXPECTED_FILE_CONTENT_3 "^/usr/foo${whitespaces_}/usr/foo/CMakeLists.txt$") diff --git a/Tests/RunCMake/CPack/RPM/PER_COMPONENT_FIELDS-VerifyResult.cmake b/Tests/RunCMake/CPack/RPM/PER_COMPONENT_FIELDS-VerifyResult.cmake deleted file mode 100644 index d7d4f9d..0000000 --- a/Tests/RunCMake/CPack/RPM/PER_COMPONENT_FIELDS-VerifyResult.cmake +++ /dev/null @@ -1,18 +0,0 @@ -function(checkPackageInfo_ TYPE FILE REGEX) - set(whitespaces_ "[\t\n\r ]*") - - getPackageInfo("${FILE}" "FILE_INFO_") - if(NOT FILE_INFO_ MATCHES "${REGEX}") - message(FATAL_ERROR "Unexpected ${TYPE} in '${FILE}'; file info: '${FILE_INFO_}'") - endif() -endfunction() - -# check package name -checkPackageInfo_("name" "${FOUND_FILE_1}" ".*Name${whitespaces_}:${whitespaces_}per_component-pkg_1") -checkPackageInfo_("name" "${FOUND_FILE_2}" ".*Name${whitespaces_}:${whitespaces_}second") -checkPackageInfo_("name" "${FOUND_FILE_3}" ".*Name${whitespaces_}:${whitespaces_}per_component-pkg_3") - -# check package group -checkPackageInfo_("group" "${FOUND_FILE_1}" ".*Group${whitespaces_}:${whitespaces_}default") -checkPackageInfo_("group" "${FOUND_FILE_2}" ".*Group${whitespaces_}:${whitespaces_}second_group") -checkPackageInfo_("group" "${FOUND_FILE_3}" ".*Group${whitespaces_}:${whitespaces_}default") diff --git a/Tests/RunCMake/CPack/RPM/PER_COMPONENT_FIELDS-specifics.cmake b/Tests/RunCMake/CPack/RPM/PER_COMPONENT_FIELDS-specifics.cmake deleted file mode 100644 index 524ef0c..0000000 --- a/Tests/RunCMake/CPack/RPM/PER_COMPONENT_FIELDS-specifics.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(CPACK_RPM_COMPONENT_INSTALL "ON") - -set(CPACK_RPM_PACKAGE_GROUP "default") -set(CPACK_RPM_PKG_2_PACKAGE_NAME "second") -set(CPACK_RPM_PKG_2_PACKAGE_GROUP "second_group") diff --git a/Tests/RunCMake/CPack/RPM/RPM_DIST-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/RPM_DIST-ExpectedFiles.cmake deleted file mode 100644 index 3b5a347..0000000 --- a/Tests/RunCMake/CPack/RPM/RPM_DIST-ExpectedFiles.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_1 "rpm_dist*.rpm") -set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/CMakeLists.txt$") diff --git a/Tests/RunCMake/CPack/RPM/RPM_SUGGESTS-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/RPM_SUGGESTS-ExpectedFiles.cmake deleted file mode 100644 index 02ebb44..0000000 --- a/Tests/RunCMake/CPack/RPM/RPM_SUGGESTS-ExpectedFiles.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_1 "rpm_suggests*.rpm") -set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/CMakeLists.txt$") diff --git a/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-no_components-stderr.txt b/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-no_components-stderr.txt deleted file mode 100644 index d80939f..0000000 --- a/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-no_components-stderr.txt +++ /dev/null @@ -1 +0,0 @@ -^CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/SINGLE_DEBUGINFO-build-no_components-subtest/_CPack_Packages/.*/RPM/SPECS/single_debuginfo.spec$ diff --git a/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-no_debuginfo-stderr.txt b/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-no_debuginfo-stderr.txt deleted file mode 100644 index 86396db..0000000 --- a/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-no_debuginfo-stderr.txt +++ /dev/null @@ -1,3 +0,0 @@ -^CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/SINGLE_DEBUGINFO-build-no_debuginfo-subtest/_CPack_Packages/.*/RPM/SPECS/single_debuginfo-headers.spec -CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/SINGLE_DEBUGINFO-build-no_debuginfo-subtest/_CPack_Packages/.*/RPM/SPECS/single_debuginfo-libs.spec -CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/SINGLE_DEBUGINFO-build-no_debuginfo-subtest/_CPack_Packages/.*/RPM/SPECS/single_debuginfo.spec$ diff --git a/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-one_component-stderr.txt b/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-one_component-stderr.txt deleted file mode 100644 index 080c4ff..0000000 --- a/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-one_component-stderr.txt +++ /dev/null @@ -1 +0,0 @@ -^CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/SINGLE_DEBUGINFO-build-one_component-subtest/_CPack_Packages/.*/RPM/SPECS/single_debuginfo-applications.spec$ diff --git a/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-one_component_main-stderr.txt b/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-one_component_main-stderr.txt deleted file mode 100644 index 665597c..0000000 --- a/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-one_component_main-stderr.txt +++ /dev/null @@ -1 +0,0 @@ -^CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/SINGLE_DEBUGINFO-build-one_component_main-subtest/_CPack_Packages/.*/RPM/SPECS/single_debuginfo.spec$ diff --git a/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-one_component_no_debuginfo-stderr.txt b/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-one_component_no_debuginfo-stderr.txt deleted file mode 100644 index b64b1f5..0000000 --- a/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-one_component_no_debuginfo-stderr.txt +++ /dev/null @@ -1 +0,0 @@ -^CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/SINGLE_DEBUGINFO-build-one_component_no_debuginfo-subtest/_CPack_Packages/.*/RPM/SPECS/single_debuginfo-applications.spec$ diff --git a/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-valid-stderr.txt b/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-valid-stderr.txt deleted file mode 100644 index f4c1bef..0000000 --- a/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-valid-stderr.txt +++ /dev/null @@ -1,3 +0,0 @@ -^CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/SINGLE_DEBUGINFO-build-valid-subtest/_CPack_Packages/.*/RPM/SPECS/single_debuginfo-headers.spec -CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/SINGLE_DEBUGINFO-build-valid-subtest/_CPack_Packages/.*/RPM/SPECS/single_debuginfo-libs.spec -CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/SINGLE_DEBUGINFO-build-valid-subtest/_CPack_Packages/.*/RPM/SPECS/single_debuginfo.spec$ diff --git a/Tests/RunCMake/CPack/RPM/SOURCE_PACKAGE-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/SOURCE_PACKAGE-ExpectedFiles.cmake deleted file mode 100644 index d6811eb..0000000 --- a/Tests/RunCMake/CPack/RPM/SOURCE_PACKAGE-ExpectedFiles.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_1 "source_package*.src.rpm") -set(EXPECTED_FILE_CONTENT_1 "^source_package-0.1.1.tar.gz${whitespaces_}source_package.spec$") diff --git a/Tests/RunCMake/CPack/RPM/default_expected_stderr.txt b/Tests/RunCMake/CPack/RPM/default_expected_stderr.txt new file mode 100644 index 0000000..4a0e4e6 --- /dev/null +++ b/Tests/RunCMake/CPack/RPM/default_expected_stderr.txt @@ -0,0 +1 @@ +^(CPackRPM: Will use GENERATED spec file: (/[^/]*)*/Tests/RunCMake/RPM/CPack/[^-]*-build((-[^-]*-subtest/)|/)_CPack_Packages/.*/RPM/SPECS/[^\.]*\.spec(\n|$))*$ diff --git a/Tests/RunCMake/CPack/RPM/packaging_COMPONENT_default.cmake b/Tests/RunCMake/CPack/RPM/packaging_COMPONENT_default.cmake new file mode 100644 index 0000000..c8b93e9 --- /dev/null +++ b/Tests/RunCMake/CPack/RPM/packaging_COMPONENT_default.cmake @@ -0,0 +1 @@ +set(CPACK_RPM_COMPONENT_INSTALL "ON") diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index 38bd0ea..092fb47 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -3,23 +3,22 @@ cmake_minimum_required(VERSION 3.1 FATAL_ERROR) include(RunCMake) include("${RunCMake_SOURCE_DIR}/CPackTestHelpers.cmake") -# args: TEST_NAME "GENERATORS" RUN_CMAKE_BUILD_STEP -run_cpack_test(MINIMAL "RPM;DEB;TGZ" false) -run_cpack_source_test(SOURCE_PACKAGE "RPM" true) -run_cpack_test(PARTIALLY_RELOCATABLE_WARNING "RPM" false) -run_cpack_test(DEB_EXTRA "DEB" false) -run_cpack_test(DEPENDENCIES "RPM;DEB" true) -run_cpack_test(EMPTY_DIR "RPM;DEB;TGZ" true) -run_cpack_test(COMPONENTS_EMPTY_DIR "RPM;DEB;TGZ" true) -run_cpack_test(CUSTOM_NAMES "RPM;DEB" true) -run_cpack_test_subtests(MAIN_COMPONENT "invalid;found" "RPM" false) -run_cpack_test(PER_COMPONENT_FIELDS "RPM;DEB" false) -run_cpack_test(RPM_DIST "RPM" false) -run_cpack_test(RPM_SUGGESTS "RPM" false) -run_cpack_test(INSTALL_SCRIPTS "RPM" false) -run_cpack_test(DEB_GENERATE_SHLIBS "DEB" true) -run_cpack_test(DEB_GENERATE_SHLIBS_LDCONFIG "DEB" true) -run_cpack_test(DEBUGINFO "RPM" true) -run_cpack_test_subtests(SINGLE_DEBUGINFO "no_main_component;one_component;one_component_main;no_debuginfo;one_component_no_debuginfo;no_components;valid" "RPM" true) -run_cpack_test(LONG_FILENAMES "DEB" false) -run_cpack_test_subtests(PACKAGE_CHECKSUM "invalid;MD5;SHA1;SHA224;SHA256;SHA384;SHA512" "TGZ" false) +# run_cpack_test args: TEST_NAME "GENERATORS" RUN_CMAKE_BUILD_STEP "PACKAGING_TYPES" +run_cpack_test(CUSTOM_NAMES "RPM;DEB" true "COMPONENT") +run_cpack_test(DEBUGINFO "RPM" true "COMPONENT") +run_cpack_test(DEPENDENCIES "RPM;DEB" true "COMPONENT") +run_cpack_test(DIST "RPM" false "MONOLITHIC") +run_cpack_test(EMPTY_DIR "RPM;DEB;TGZ" true "MONOLITHIC;COMPONENT") +run_cpack_test(EXTRA "DEB" false "COMPONENT") +run_cpack_test(GENERATE_SHLIBS "DEB" true "COMPONENT") +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_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") +run_cpack_test_subtests(SINGLE_DEBUGINFO "no_main_component;one_component;one_component_main;no_debuginfo;one_component_no_debuginfo;no_components;valid" "RPM" true "CUSTOM") +run_cpack_source_test(SOURCE_PACKAGE "RPM") +run_cpack_test(SUGGESTS "RPM" false "MONOLITHIC") diff --git a/Tests/RunCMake/CPack/TGZ/COMPONENTS_EMPTY_DIR-ExpectedFiles.cmake b/Tests/RunCMake/CPack/TGZ/COMPONENTS_EMPTY_DIR-ExpectedFiles.cmake deleted file mode 100644 index 26e2ab0..0000000 --- a/Tests/RunCMake/CPack/TGZ/COMPONENTS_EMPTY_DIR-ExpectedFiles.cmake +++ /dev/null @@ -1,3 +0,0 @@ -set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_1 "components_empty_dir*.tar.gz") -set(EXPECTED_FILE_CONTENT_1 "^[^\n]*empty/$") diff --git a/Tests/RunCMake/CPack/TGZ/EMPTY_DIR-ExpectedFiles.cmake b/Tests/RunCMake/CPack/TGZ/EMPTY_DIR-ExpectedFiles.cmake deleted file mode 100644 index a75514a..0000000 --- a/Tests/RunCMake/CPack/TGZ/EMPTY_DIR-ExpectedFiles.cmake +++ /dev/null @@ -1,3 +0,0 @@ -set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_1 "empty_dir*.tar.gz") -set(EXPECTED_FILE_CONTENT_1 "^[^\n]*empty_dir-0.1.1-[^\n]*/empty/$") diff --git a/Tests/RunCMake/CPack/TGZ/Helpers.cmake b/Tests/RunCMake/CPack/TGZ/Helpers.cmake index f14d532..4a194c6 100644 --- a/Tests/RunCMake/CPack/TGZ/Helpers.cmake +++ b/Tests/RunCMake/CPack/TGZ/Helpers.cmake @@ -8,3 +8,55 @@ function(getPackageContent FILE RESULT_VAR) 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() diff --git a/Tests/RunCMake/CPack/TGZ/MINIMAL-ExpectedFiles.cmake b/Tests/RunCMake/CPack/TGZ/MINIMAL-ExpectedFiles.cmake deleted file mode 100644 index 5c31f27..0000000 --- a/Tests/RunCMake/CPack/TGZ/MINIMAL-ExpectedFiles.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_1 "minimal*.tar.gz") -set(EXPECTED_FILE_CONTENT_1 "^[^\n]*minimal-0.1.1-[^\n]*/foo/\n[^\n]*minimal-0.1.1-[^\n]*/foo/CMakeLists.txt$") diff --git a/Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-ExpectedFiles.cmake b/Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-ExpectedFiles.cmake deleted file mode 100644 index 205dcd8..0000000 --- a/Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-ExpectedFiles.cmake +++ /dev/null @@ -1,9 +0,0 @@ -set(whitespaces_ "[\t\n\r ]*") - -set(EXPECTED_FILES_COUNT "0") - -if (NOT ${RunCMake_SUBTEST_SUFFIX} MATCHES "invalid") - set(EXPECTED_FILES_COUNT "1") - set(EXPECTED_FILE_1 "package_checksum*.tar.gz") - set(EXPECTED_FILE_CONTENT_1 "^[^\n]*package_checksum*-[^\n]*/foo/\n[^\n]*package_checksum-[^\n]*/foo/CMakeLists.txt$") -endif() diff --git a/Tests/RunCMake/CPack/TGZ/COMPONENTS_EMPTY_DIR-specifics.cmake b/Tests/RunCMake/CPack/TGZ/packaging_COMPONENT_default.cmake index 81a5035..81a5035 100644 --- a/Tests/RunCMake/CPack/TGZ/COMPONENTS_EMPTY_DIR-specifics.cmake +++ b/Tests/RunCMake/CPack/TGZ/packaging_COMPONENT_default.cmake diff --git a/Tests/RunCMake/CPack/VerifyResult.cmake b/Tests/RunCMake/CPack/VerifyResult.cmake index ad2a651..59751a7 100644 --- a/Tests/RunCMake/CPack/VerifyResult.cmake +++ b/Tests/RunCMake/CPack/VerifyResult.cmake @@ -1,5 +1,28 @@ cmake_minimum_required(VERSION ${CMAKE_VERSION} FATAL_ERROR) +function(findExpectedFile FILE_NO RESULT_VAR) + if(NOT DEFINED EXPECTED_FILE_${FILE_NO}) # explicit file name regex was not provided - construct one from other data + # set defaults if parameters are not provided + if(NOT DEFINED EXPECTED_FILE_${FILE_NO}_NAME) + string(TOLOWER "${RunCMake_TEST_FILE_PREFIX}" EXPECTED_FILE_${FILE_NO}_NAME) + endif() + if(NOT DEFINED EXPECTED_FILE_${FILE_NO}_VERSION) + set(EXPECTED_FILE_${FILE_NO}_VERSION "0.1.1") + endif() + if(NOT DEFINED EXPECTED_FILE_${FILE_NO}_REVISION) + set(EXPECTED_FILE_${FILE_NO}_REVISION "1") + endif() + + getPackageNameGlobexpr("${EXPECTED_FILE_${FILE_NO}_NAME}" + "${EXPECTED_FILE_${FILE_NO}_COMPONENT}" "${EXPECTED_FILE_${FILE_NO}_VERSION}" + "${EXPECTED_FILE_${FILE_NO}_REVISION}" "${FILE_NO}" "EXPECTED_FILE_${FILE_NO}") + endif() + + file(GLOB found_file_ RELATIVE "${bin_dir}" "${EXPECTED_FILE_${FILE_NO}}") + + set(${RESULT_VAR} "${found_file_}" PARENT_SCOPE) +endfunction() + include("${config_file}") include("${src_dir}/${GENERATOR_TYPE}/Helpers.cmake") @@ -10,21 +33,38 @@ file(READ "${config_file}" config_file_content) set(output_error_message "\nCPack output: '${output}'\nCPack error: '${error}';\nCPack result: '${PACKAGING_RESULT}';\nconfig file: '${config_file_content}'") -# check that expected generated files exist and contain expected content -include("${src_dir}/${GENERATOR_TYPE}/${RunCMake_TEST_FILE_PREFIX}-ExpectedFiles.cmake") +# generate default expected files data +include("${src_dir}/tests/${RunCMake_TEST_FILE_PREFIX}/ExpectedFiles.cmake") +# check that expected generated files exist and contain expected content if(NOT EXPECTED_FILES_COUNT EQUAL 0) foreach(file_no_ RANGE 1 ${EXPECTED_FILES_COUNT}) - file(GLOB FOUND_FILE_${file_no_} RELATIVE "${bin_dir}" "${EXPECTED_FILE_${file_no_}}") + findExpectedFile("${file_no_}" "FOUND_FILE_${file_no_}") list(APPEND foundFiles_ "${FOUND_FILE_${file_no_}}") list(LENGTH FOUND_FILE_${file_no_} foundFilesCount_) if(foundFilesCount_ EQUAL 1) unset(PACKAGE_CONTENT) - getPackageContent("${bin_dir}/${FOUND_FILE_${file_no_}}" "PACKAGE_CONTENT") - string(REGEX MATCH "${EXPECTED_FILE_CONTENT_${file_no_}}" - expected_content_list "${PACKAGE_CONTENT}") + if(DEFINED EXPECTED_FILE_CONTENT_${file_no_}) + getPackageContent("${bin_dir}/${FOUND_FILE_${file_no_}}" "PACKAGE_CONTENT") + + string(REGEX MATCH "${EXPECTED_FILE_CONTENT_${file_no_}}" + expected_content_list "${PACKAGE_CONTENT}") + else() # use content list + getPackageContentList("${bin_dir}/${FOUND_FILE_${file_no_}}" "PACKAGE_CONTENT") + set(EXPECTED_FILE_CONTENT_${file_no_} "${EXPECTED_FILE_CONTENT_${file_no_}_LIST}") + toExpectedContentList("${file_no_}" "EXPECTED_FILE_CONTENT_${file_no_}") + + list(SORT PACKAGE_CONTENT) + list(SORT EXPECTED_FILE_CONTENT_${file_no_}) + + if(PACKAGE_CONTENT STREQUAL EXPECTED_FILE_CONTENT_${file_no_}) + set(expected_content_list TRUE) + else() + set(expected_content_list FALSE) + endif() + endif() if(NOT expected_content_list) string(REPLACE "\n" "\n actual> " msg_actual "\n${PACKAGE_CONTENT}") @@ -40,6 +80,7 @@ if(NOT EXPECTED_FILES_COUNT EQUAL 0) "Found more than one file for file No. '${file_no_}'!" " Found files count '${foundFilesCount_}'." " Files: '${FOUND_FILE_${file_no_}}'" + " Globbing expression: '${EXPECTED_FILE_${file_no_}}'" "${output_error_message}") endif() endforeach() @@ -84,11 +125,9 @@ else() endif() # handle additional result verifications -if(EXISTS "${src_dir}/${GENERATOR_TYPE}/${RunCMake_TEST_FILE_PREFIX}-VerifyResult.cmake") - include("${src_dir}/${GENERATOR_TYPE}/${RunCMake_TEST_FILE_PREFIX}-VerifyResult.cmake") -else() - # by default only print out output and error so that they can be compared by - # regex - message(STATUS "${output}") - message("${error}") +if(EXISTS "${src_dir}/tests/${RunCMake_TEST_FILE_PREFIX}/VerifyResult.cmake") + include("${src_dir}/tests/${RunCMake_TEST_FILE_PREFIX}/VerifyResult.cmake") endif() + +message(STATUS "${output}") +message("${error}") diff --git a/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/ExpectedFiles.cmake new file mode 100644 index 0000000..ae5f0af --- /dev/null +++ b/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/ExpectedFiles.cmake @@ -0,0 +1,12 @@ +set(EXPECTED_FILES_COUNT "3") +set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE) +set(EXPECTED_FILE_1_COMPONENT "pkg_1") +set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") +set(EXPECTED_FILE_2_NAME "second") +set(EXPECTED_FILE_CONTENT_2_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") +set(EXPECTED_FILE_CONTENT_3_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") + +if(GENERATOR_TYPE STREQUAL "DEB" OR GENERATOR_TYPE STREQUAL "RPM") + string(TOLOWER "${GENERATOR_TYPE}" file_extension_) + set(EXPECTED_FILE_3 "pkg_3_abc.${file_extension_}") +endif() diff --git a/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/test.cmake b/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/test.cmake new file mode 100644 index 0000000..0c2b37b --- /dev/null +++ b/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/test.cmake @@ -0,0 +1,14 @@ +if(GENERATOR_TYPE STREQUAL "DEB" OR GENERATOR_TYPE STREQUAL "RPM") + if(GENERATOR_TYPE STREQUAL "DEB") + set(generator_type_suffix_ "IAN") # not entirely compatible... + endif() + + set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_FILE_NAME "${GENERATOR_TYPE}-DEFAULT") + set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_PKG_2_PACKAGE_NAME "second") + string(TOLOWER "${GENERATOR_TYPE}" file_extension_) + set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_PKG_3_FILE_NAME "pkg_3_abc.${file_extension_}") +endif() + +install(FILES CMakeLists.txt DESTINATION foo COMPONENT pkg_1) +install(FILES CMakeLists.txt DESTINATION foo COMPONENT pkg_2) +install(FILES CMakeLists.txt DESTINATION foo COMPONENT pkg_3) diff --git a/Tests/RunCMake/CPack/tests/DEBUGINFO/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/DEBUGINFO/ExpectedFiles.cmake new file mode 100644 index 0000000..06e56d3 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DEBUGINFO/ExpectedFiles.cmake @@ -0,0 +1,16 @@ +set(whitespaces_ "[\t\n\r ]*") + +set(EXPECTED_FILES_COUNT "5") +set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE) + +set(EXPECTED_FILE_1_COMPONENT "applications") +set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/test_prog") +set(EXPECTED_FILE_2 "debuginfo*-headers.rpm") +set(EXPECTED_FILE_CONTENT_2_LIST "/usr;/usr/bar;/usr/bar/CMakeLists.txt") +set(EXPECTED_FILE_3 "debuginfo*-libs.rpm") +set(EXPECTED_FILE_CONTENT_3_LIST "/usr;/usr/bas;/usr/bas/libtest_lib.so") + +set(EXPECTED_FILE_4_COMPONENT "applications-debuginfo") +set(EXPECTED_FILE_CONTENT_4 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp.*") +set(EXPECTED_FILE_5_COMPONENT "libs-debuginfo") +set(EXPECTED_FILE_CONTENT_5 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/test_lib.cpp.*") diff --git a/Tests/RunCMake/CPack/DEBUGINFO.cmake b/Tests/RunCMake/CPack/tests/DEBUGINFO/test.cmake index d98b682..0642d83 100644 --- a/Tests/RunCMake/CPack/DEBUGINFO.cmake +++ b/Tests/RunCMake/CPack/tests/DEBUGINFO/test.cmake @@ -6,8 +6,6 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "PGI") string(APPEND CMAKE_SHARED_LINKER_FLAGS "-Wl,--build-id") endif() -set(CPACK_RPM_COMPONENT_INSTALL "ON") - set(CMAKE_BUILD_TYPE Debug) file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.hpp" @@ -30,5 +28,3 @@ set(CPACK_RPM_APPLICATIONS_DEBUGINFO_PACKAGE ON) set(CPACK_RPM_LIBS_DEBUGINFO_PACKAGE ON) set(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX "/src") - -set(CPACK_PACKAGE_NAME "debuginfo") diff --git a/Tests/RunCMake/CPack/tests/DEPENDENCIES/DEB-stderr.txt b/Tests/RunCMake/CPack/tests/DEPENDENCIES/DEB-stderr.txt new file mode 100644 index 0000000..5df274a --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DEPENDENCIES/DEB-stderr.txt @@ -0,0 +1 @@ +^CPackDeb: ((- Generating dependency list)|(Using only user-provided dependencies because dpkg-shlibdeps is not found\.))$ diff --git a/Tests/RunCMake/CPack/tests/DEPENDENCIES/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/DEPENDENCIES/ExpectedFiles.cmake new file mode 100644 index 0000000..3b280ba --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DEPENDENCIES/ExpectedFiles.cmake @@ -0,0 +1,18 @@ +set(EXPECTED_FILES_COUNT "5") +set(EXPECTED_FILE_1_COMPONENT "applications") +set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/test_prog") +set(EXPECTED_FILE_2_COMPONENT "applications_auto") +set(EXPECTED_FILE_CONTENT_2_LIST "/usr;/usr/foo_auto;/usr/foo_auto/test_prog") +set(EXPECTED_FILE_3_COMPONENT "headers") +set(EXPECTED_FILE_CONTENT_3_LIST "/usr;/usr/bar;/usr/bar/CMakeLists.txt") +set(EXPECTED_FILE_4_COMPONENT "libs") +set(EXPECTED_FILE_CONTENT_4_LIST "/usr/bas;/usr/bas/libtest_lib.so") +set(EXPECTED_FILE_5_COMPONENT "libs_auto") +set(EXPECTED_FILE_CONTENT_5_LIST "/usr;/usr/bas_auto;/usr/bas_auto/libtest_lib.so") + +if(GENERATOR_TYPE STREQUAL "DEB") + set(whitespaces_ "[\t\n\r ]*") + # dynamic lib extension is .so on Linux and .dylib on Mac so we will use a wildcard .* for it + set(EXPECTED_FILE_CONTENT_4 "^.*/usr/bas${whitespaces_}.*/usr/bas/libtest_lib\\..*$") + set(EXPECTED_FILE_CONTENT_5 "^.*/usr/bas_auto${whitespaces_}.*/usr/bas_auto/libtest_lib\\..*$") +endif() diff --git a/Tests/RunCMake/CPack/tests/DEPENDENCIES/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/DEPENDENCIES/VerifyResult.cmake new file mode 100644 index 0000000..7923148 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DEPENDENCIES/VerifyResult.cmake @@ -0,0 +1,82 @@ +if(GENERATOR_TYPE STREQUAL "DEB") + function(checkDependencies_ FILE REGEX) + set(whitespaces_ "[\t\n\r ]*") + + getPackageInfo("${FILE}" "FILE_INFO_") + if(NOT FILE_INFO_ MATCHES "${REGEX}") + message(FATAL_ERROR "Unexpected dependencies in '${FILE}'; file info: '${FILE_INFO_}'") + endif() + endfunction() + + foreach(dependency_type_ DEPENDS CONFLICTS ENHANCES BREAKS REPLACES RECOMMENDS SUGGESTS) + string(TOLOWER "${dependency_type_}" lower_dependency_type_) + string(SUBSTRING ${lower_dependency_type_} 1 -1 lower_dependency_type_tail_) + string(SUBSTRING ${dependency_type_} 0 1 dependency_type_head_) + set(dependency_type_name_ "${dependency_type_head_}${lower_dependency_type_tail_}") + + checkDependencies_("${FOUND_FILE_1}" ".*${dependency_type_name_}${whitespaces_}:${whitespaces_}${lower_dependency_type_}-application, ${lower_dependency_type_}-application-b.*") + checkDependencies_("${FOUND_FILE_2}" ".*${dependency_type_name_}${whitespaces_}:${whitespaces_}.*${lower_dependency_type_}-application, ${lower_dependency_type_}-application-b.*") + checkDependencies_("${FOUND_FILE_3}" ".*${dependency_type_name_}${whitespaces_}:${whitespaces_}${lower_dependency_type_}-headers.*") + checkDependencies_("${FOUND_FILE_4}" ".*${dependency_type_name_}${whitespaces_}:${whitespaces_}${lower_dependency_type_}-default, ${lower_dependency_type_}-default-b.*") + checkDependencies_("${FOUND_FILE_5}" ".*${dependency_type_name_}${whitespaces_}:${whitespaces_}${lower_dependency_type_}-default, ${lower_dependency_type_}-default-b.*") + endforeach() + + checkDependencies_("${FOUND_FILE_1}" ".*Provides${whitespaces_}:${whitespaces_}provided-default, provided-default-b") + checkDependencies_("${FOUND_FILE_2}" ".*Provides${whitespaces_}:${whitespaces_}provided-default, provided-default-b") + checkDependencies_("${FOUND_FILE_3}" ".*Provides${whitespaces_}:${whitespaces_}provided-default, provided-default-b") + checkDependencies_("${FOUND_FILE_4}" ".*Provides${whitespaces_}:${whitespaces_}provided-lib.*") + checkDependencies_("${FOUND_FILE_5}" ".*Provides${whitespaces_}:${whitespaces_}provided-lib_auto.*, provided-lib_auto-b.*") + + # PREDEPENDS + checkDependencies_("${FOUND_FILE_1}" ".*Pre-Depends${whitespaces_}:${whitespaces_}predepends-application, predepends-application-b.*") + checkDependencies_("${FOUND_FILE_2}" ".*Pre-Depends${whitespaces_}:${whitespaces_}.*predepends-application, predepends-application-b.*") + checkDependencies_("${FOUND_FILE_3}" ".*Pre-Depends${whitespaces_}:${whitespaces_}predepends-headers.*") + checkDependencies_("${FOUND_FILE_4}" ".*Pre-Depends${whitespaces_}:${whitespaces_}predepends-default, predepends-default-b.*") + checkDependencies_("${FOUND_FILE_5}" ".*Pre-Depends${whitespaces_}:${whitespaces_}predepends-default, predepends-default-b.*") +elseif(GENERATOR_TYPE STREQUAL "RPM") + function(checkDependencies_ FILE TYPE COMPARE_LIST) + set(whitespaces_ "[\t\n\r ]*") + + execute_process(COMMAND ${RPM_EXECUTABLE} -qp --${TYPE} ${FILE} + WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" + OUTPUT_VARIABLE FILE_DEPENDENCIES_ + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + + string(REPLACE "\n" ";" FILE_DEPENDENCIES_LIST_ "${FILE_DEPENDENCIES_}") + + foreach(COMPARE_REGEX_ IN LISTS COMPARE_LIST) + unset(FOUND_) + + foreach(COMPARE_ IN LISTS FILE_DEPENDENCIES_LIST_) + if(COMPARE_ MATCHES "${COMPARE_REGEX_}") + set(FOUND_ true) + break() + endif() + endforeach() + + if(NOT FOUND_) + message(FATAL_ERROR "Missing dependencies in '${FILE}'; check type: '${TYPE}'; file info: '${FILE_DEPENDENCIES_}'; missing: '${COMPARE_REGEX_}'") + endif() + endforeach() + endfunction() + + # TODO add tests for what should not be present in lists + checkDependencies_("${FOUND_FILE_1}" "requires" "depend-application;depend-application-b") + checkDependencies_("${FOUND_FILE_2}" "requires" "depend-application;depend-application-b;libtest_lib\\.so.*") + checkDependencies_("${FOUND_FILE_3}" "requires" "depend-headers") + checkDependencies_("${FOUND_FILE_4}" "requires" "depend-default;depend-default-b") + checkDependencies_("${FOUND_FILE_5}" "requires" "depend-default;depend-default-b") + + checkDependencies_("${FOUND_FILE_1}" "conflicts" "conflicts-application;conflicts-application-b") + checkDependencies_("${FOUND_FILE_2}" "conflicts" "conflicts-application;conflicts-application-b") + checkDependencies_("${FOUND_FILE_3}" "conflicts" "conflicts-headers") + checkDependencies_("${FOUND_FILE_4}" "conflicts" "conflicts-default;conflicts-default-b") + checkDependencies_("${FOUND_FILE_5}" "conflicts" "conflicts-default;conflicts-default-b") + + checkDependencies_("${FOUND_FILE_1}" "provides" "provided-default;provided-default-b") + checkDependencies_("${FOUND_FILE_2}" "provides" "provided-default;provided-default-b") + checkDependencies_("${FOUND_FILE_3}" "provides" "provided-default;provided-default-b") + checkDependencies_("${FOUND_FILE_4}" "provides" "provided-lib") + checkDependencies_("${FOUND_FILE_5}" "provides" "provided-lib_auto;provided-lib_auto-b") +endif() diff --git a/Tests/RunCMake/CPack/tests/DEPENDENCIES/test.cmake b/Tests/RunCMake/CPack/tests/DEPENDENCIES/test.cmake new file mode 100644 index 0000000..fbd786e --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DEPENDENCIES/test.cmake @@ -0,0 +1,60 @@ +if(GENERATOR_TYPE STREQUAL "DEB" OR GENERATOR_TYPE STREQUAL "RPM") + if(GENERATOR_TYPE STREQUAL "DEB") + # false by default + set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS FALSE) + # FIXME can not be tested as libraries first have to be part of a package in order + # to determine their dependencies and we can not be certain if there will be any + set(CPACK_DEBIAN_APPLICATIONS_AUTO_PACKAGE_SHLIBDEPS TRUE) + + foreach(dependency_type_ DEPENDS PREDEPENDS ENHANCES BREAKS REPLACES RECOMMENDS SUGGESTS) + string(TOLOWER "${dependency_type_}" lower_dependency_type_) + + set(CPACK_DEBIAN_PACKAGE_${dependency_type_} "${lower_dependency_type_}-default, ${lower_dependency_type_}-default-b") + set(CPACK_DEBIAN_APPLICATIONS_PACKAGE_${dependency_type_} "${lower_dependency_type_}-application, ${lower_dependency_type_}-application-b") + set(CPACK_DEBIAN_APPLICATIONS_AUTO_PACKAGE_${dependency_type_} "${lower_dependency_type_}-application, ${lower_dependency_type_}-application-b") + set(CPACK_DEBIAN_HEADERS_PACKAGE_${dependency_type_} "${lower_dependency_type_}-headers") + endforeach() + + set(generator_type_suffix_ "IAN") # not entirely compatible... + else() # RPM + # FIXME auto autoprov is not tested at the moment as Ubuntu 15.04 rpmbuild + # does not use them correctly: https://bugs.launchpad.net/rpm/+bug/1475755 + set(CPACK_RPM_PACKAGE_AUTOREQ "no") + set(CPACK_RPM_PACKAGE_AUTOPROV "no") + set(CPACK_RPM_APPLICATIONS_AUTO_PACKAGE_AUTOREQPROV "yes") + set(CPACK_RPM_LIBS_AUTO_PACKAGE_AUTOREQPROV "yes") + + set(CPACK_RPM_PACKAGE_REQUIRES "depend-default, depend-default-b") + set(CPACK_RPM_APPLICATIONS_PACKAGE_REQUIRES "depend-application, depend-application-b") + set(CPACK_RPM_APPLICATIONS_AUTO_PACKAGE_REQUIRES "depend-application, depend-application-b") + set(CPACK_RPM_HEADERS_PACKAGE_REQUIRES "depend-headers") + endif() + + set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_PACKAGE_CONFLICTS "conflicts-default, conflicts-default-b") + set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_APPLICATIONS_PACKAGE_CONFLICTS "conflicts-application, conflicts-application-b") + set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_APPLICATIONS_AUTO_PACKAGE_CONFLICTS "conflicts-application, conflicts-application-b") + set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_HEADERS_PACKAGE_CONFLICTS "conflicts-headers") + + set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_PACKAGE_PROVIDES "provided-default, provided-default-b") + set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_LIBS_PACKAGE_PROVIDES "provided-lib") + set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_LIBS_AUTO_PACKAGE_PROVIDES "provided-lib_auto, provided-lib_auto-b") +endif() + +set(CMAKE_BUILD_WITH_INSTALL_RPATH 1) + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.hpp" + "int test_lib();\n") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp" + "#include \"test_lib.hpp\"\nint test_lib() {return 0;}\n") +add_library(test_lib SHARED "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp") + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp" + "#include \"test_lib.hpp\"\nint main() {return test_lib();}\n") +add_executable(test_prog "${CMAKE_CURRENT_BINARY_DIR}/main.cpp") +target_link_libraries(test_prog test_lib) + +install(TARGETS test_prog DESTINATION foo COMPONENT applications) +install(TARGETS test_prog DESTINATION foo_auto COMPONENT applications_auto) +install(FILES CMakeLists.txt DESTINATION bar COMPONENT headers) +install(TARGETS test_lib DESTINATION bas COMPONENT libs) +install(TARGETS test_lib DESTINATION bas_auto COMPONENT libs_auto) diff --git a/Tests/RunCMake/CPack/tests/DIST/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/DIST/ExpectedFiles.cmake new file mode 100644 index 0000000..6142eb3 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DIST/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/RPM/RPM_DIST-VerifyResult.cmake b/Tests/RunCMake/CPack/tests/DIST/VerifyResult.cmake index 7375ecc..7375ecc 100644 --- a/Tests/RunCMake/CPack/RPM/RPM_DIST-VerifyResult.cmake +++ b/Tests/RunCMake/CPack/tests/DIST/VerifyResult.cmake diff --git a/Tests/RunCMake/CPack/RPM_DIST.cmake b/Tests/RunCMake/CPack/tests/DIST/test.cmake index eb2a123..6bdd2c0 100644 --- a/Tests/RunCMake/CPack/RPM_DIST.cmake +++ b/Tests/RunCMake/CPack/tests/DIST/test.cmake @@ -1,4 +1,3 @@ install(FILES CMakeLists.txt DESTINATION foo COMPONENT test) set(CPACK_RPM_PACKAGE_RELEASE_DIST ON) -set(CPACK_PACKAGE_NAME "rpm_dist") diff --git a/Tests/RunCMake/CPack/tests/EMPTY_DIR/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/EMPTY_DIR/ExpectedFiles.cmake new file mode 100644 index 0000000..650687c --- /dev/null +++ b/Tests/RunCMake/CPack/tests/EMPTY_DIR/ExpectedFiles.cmake @@ -0,0 +1,7 @@ +set(EXPECTED_FILES_COUNT "1") +set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE) +set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/empty") + +if(PACKAGING_TYPE STREQUAL "COMPONENT") + set(EXPECTED_FILE_1_COMPONENT "test") +endif() diff --git a/Tests/RunCMake/CPack/tests/EMPTY_DIR/test.cmake b/Tests/RunCMake/CPack/tests/EMPTY_DIR/test.cmake new file mode 100644 index 0000000..cd2c9fd --- /dev/null +++ b/Tests/RunCMake/CPack/tests/EMPTY_DIR/test.cmake @@ -0,0 +1,14 @@ +if(GENERATOR_TYPE STREQUAL "DEB" OR GENERATOR_TYPE STREQUAL "RPM") + if(GENERATOR_TYPE STREQUAL "DEB") + set(generator_type_suffix_ "IAN") # not entirely compatible... + endif() + + set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_FILE_NAME "${GENERATOR_TYPE}-DEFAULT") +endif() + +install(DIRECTORY DESTINATION empty + COMPONENT test) + +if(PACKAGING_TYPE STREQUAL "COMPONENT") + set(CPACK_COMPONENTS_ALL test) +endif() diff --git a/Tests/RunCMake/CPack/tests/EXTRA/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/EXTRA/ExpectedFiles.cmake new file mode 100644 index 0000000..ded2923 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/EXTRA/ExpectedFiles.cmake @@ -0,0 +1,8 @@ +set(EXPECTED_FILES_COUNT "3") +set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE) +set(EXPECTED_FILE_1_COMPONENT "foo") +set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") +set(EXPECTED_FILE_2_COMPONENT "bar") +set(EXPECTED_FILE_CONTENT_2_LIST "/usr;/usr/bar;/usr/bar/CMakeLists.txt") +set(EXPECTED_FILE_3_COMPONENT "bas") +set(EXPECTED_FILE_CONTENT_3_LIST "/usr;/usr/bas;/usr/bas/CMakeLists.txt") diff --git a/Tests/RunCMake/CPack/DEB/DEB_EXTRA-VerifyResult.cmake b/Tests/RunCMake/CPack/tests/EXTRA/VerifyResult.cmake index 85e137f..85e137f 100644 --- a/Tests/RunCMake/CPack/DEB/DEB_EXTRA-VerifyResult.cmake +++ b/Tests/RunCMake/CPack/tests/EXTRA/VerifyResult.cmake diff --git a/Tests/RunCMake/CPack/DEB_EXTRA.cmake b/Tests/RunCMake/CPack/tests/EXTRA/test.cmake index 189d123..efa6dac 100644 --- a/Tests/RunCMake/CPack/DEB_EXTRA.cmake +++ b/Tests/RunCMake/CPack/tests/EXTRA/test.cmake @@ -32,8 +32,4 @@ endforeach() set(CPACK_DEBIAN_BAR_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_BINARY_DIR}/bar/preinst;${CMAKE_CURRENT_BINARY_DIR}/bar/prerm") -set(CPACK_PACKAGE_NAME "deb_extra") -set(CPACK_PACKAGE_CONTACT "someone") set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") - -set(CPACK_DEB_COMPONENT_INSTALL ON) diff --git a/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/DEB-Prerequirements.cmake b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/DEB-Prerequirements.cmake new file mode 100644 index 0000000..be44b2e --- /dev/null +++ b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/DEB-Prerequirements.cmake @@ -0,0 +1,7 @@ +function(get_test_prerequirements found_var config_file) + include(${config_file}) + + if(READELF_EXECUTABLE) + set(${found_var} true PARENT_SCOPE) + endif() +endfunction() diff --git a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/ExpectedFiles.cmake index a8efb61..ccb5ef0 100644 --- a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/ExpectedFiles.cmake @@ -1,6 +1,6 @@ set(whitespaces_ "[\t\n\r ]*") set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_1 "generate_shlibs_0.1.1-1_*.deb") +set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE) # dynamic lib extension is .so on Linux and .dylib on Mac so we will use a wildcard .* for it set(EXPECTED_FILE_CONTENT_1 "^.*/usr/foo${whitespaces_}.*/usr/foo/libtest_lib\\..*$") diff --git a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-VerifyResult.cmake b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/VerifyResult.cmake index b1952ef..b1952ef 100644 --- a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-VerifyResult.cmake +++ b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/VerifyResult.cmake diff --git a/Tests/RunCMake/CPack/DEB_GENERATE_SHLIBS.cmake b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/test.cmake index 1aeb06f..90351ba 100644 --- a/Tests/RunCMake/CPack/DEB_GENERATE_SHLIBS.cmake +++ b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/test.cmake @@ -1,5 +1,3 @@ -set(CPACK_PACKAGE_CONTACT "someone") -set(CPACK_DEB_COMPONENT_INSTALL "ON") set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS "ON") @@ -14,5 +12,3 @@ add_library(test_lib SHARED "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp") set_target_properties(test_lib PROPERTIES SOVERSION "0.8") install(TARGETS test_lib DESTINATION foo COMPONENT libs) - -set(CPACK_PACKAGE_NAME "generate_shlibs") diff --git a/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS_LDCONFIG/DEB-Prerequirements.cmake b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS_LDCONFIG/DEB-Prerequirements.cmake new file mode 100644 index 0000000..be44b2e --- /dev/null +++ b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS_LDCONFIG/DEB-Prerequirements.cmake @@ -0,0 +1,7 @@ +function(get_test_prerequirements found_var config_file) + include(${config_file}) + + if(READELF_EXECUTABLE) + set(${found_var} true PARENT_SCOPE) + endif() +endfunction() diff --git a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS_LDCONFIG/ExpectedFiles.cmake index 9a9dee3..d66c044 100644 --- a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS_LDCONFIG/ExpectedFiles.cmake @@ -1,6 +1,6 @@ set(whitespaces_ "[\t\n\r ]*") set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_1 "generate_shlibs_ldconfig_0.1.1-1_*.deb") +set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE) # dynamic lib extension is .so on Linux and .dylib on Mac so we will use a wildcard .* for it set(EXPECTED_FILE_CONTENT_1 "^.*/usr/lib${whitespaces_}.*/usr/lib/libtest_lib\\..*$") diff --git a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-VerifyResult.cmake b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS_LDCONFIG/VerifyResult.cmake index 422cfbe..422cfbe 100644 --- a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-VerifyResult.cmake +++ b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS_LDCONFIG/VerifyResult.cmake diff --git a/Tests/RunCMake/CPack/DEB_GENERATE_SHLIBS_LDCONFIG.cmake b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS_LDCONFIG/test.cmake index f58c876..15c496b 100644 --- a/Tests/RunCMake/CPack/DEB_GENERATE_SHLIBS_LDCONFIG.cmake +++ b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS_LDCONFIG/test.cmake @@ -1,5 +1,3 @@ -set(CPACK_PACKAGE_CONTACT "someone") -set(CPACK_DEB_COMPONENT_INSTALL "ON") set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS "ON") @@ -15,5 +13,3 @@ add_library(test_lib SHARED "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp") set_target_properties(test_lib PROPERTIES SOVERSION "0.8") install(TARGETS test_lib LIBRARY DESTINATION lib COMPONENT libs NAMELINK_SKIP) - -set(CPACK_PACKAGE_NAME "generate_shlibs_ldconfig") diff --git a/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/ExpectedFiles.cmake new file mode 100644 index 0000000..44346ab --- /dev/null +++ b/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/ExpectedFiles.cmake @@ -0,0 +1,5 @@ +set(EXPECTED_FILES_COUNT "2") +set(EXPECTED_FILE_1_COMPONENT "foo") +set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") +set(EXPECTED_FILE_2_COMPONENT "bar") +set(EXPECTED_FILE_CONTENT_2_LIST "/usr;/usr/bar;/usr/bar/CMakeLists.txt") diff --git a/Tests/RunCMake/CPack/RPM/INSTALL_SCRIPTS-VerifyResult.cmake b/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/VerifyResult.cmake index d7d82f2..d7d82f2 100644 --- a/Tests/RunCMake/CPack/RPM/INSTALL_SCRIPTS-VerifyResult.cmake +++ b/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/VerifyResult.cmake diff --git a/Tests/RunCMake/CPack/INSTALL_SCRIPTS.cmake b/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/test.cmake index 13aa77b..fb1b8de 100644 --- a/Tests/RunCMake/CPack/INSTALL_SCRIPTS.cmake +++ b/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/test.cmake @@ -1,3 +1,23 @@ +if(GENERATOR_TYPE STREQUAL "RPM") + set(CPACK_RPM_PRE_INSTALL_SCRIPT_FILE + "${CMAKE_CURRENT_BINARY_DIR}/pre_install.sh") + set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE + "${CMAKE_CURRENT_BINARY_DIR}/post_install.sh") + set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE + "${CMAKE_CURRENT_BINARY_DIR}/pre_uninstall.sh") + set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE + "${CMAKE_CURRENT_BINARY_DIR}/post_uninstall.sh") + + set(CPACK_RPM_foo_PRE_INSTALL_SCRIPT_FILE + "${CMAKE_CURRENT_BINARY_DIR}/pre_install_foo.sh") + set(CPACK_RPM_foo_POST_INSTALL_SCRIPT_FILE + "${CMAKE_CURRENT_BINARY_DIR}/post_install_foo.sh") + set(CPACK_RPM_foo_PRE_UNINSTALL_SCRIPT_FILE + "${CMAKE_CURRENT_BINARY_DIR}/pre_uninstall_foo.sh") + set(CPACK_RPM_foo_POST_UNINSTALL_SCRIPT_FILE + "${CMAKE_CURRENT_BINARY_DIR}/post_uninstall_foo.sh") +endif() + set(CMAKE_BUILD_WITH_INSTALL_RPATH 1) # default @@ -22,5 +42,3 @@ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/post_uninstall_foo.sh" install(FILES CMakeLists.txt DESTINATION foo COMPONENT foo) install(FILES CMakeLists.txt DESTINATION bar COMPONENT bar) - -set(CPACK_PACKAGE_NAME "install_scripts") diff --git a/Tests/RunCMake/CPack/tests/LONG_FILENAMES/DEB-Prerequirements.cmake b/Tests/RunCMake/CPack/tests/LONG_FILENAMES/DEB-Prerequirements.cmake new file mode 100644 index 0000000..ddd16e5 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/LONG_FILENAMES/DEB-Prerequirements.cmake @@ -0,0 +1,7 @@ +function(get_test_prerequirements found_var config_file) + include(${config_file}) + + if(FAKEROOT_EXECUTABLE) + set(${found_var} true PARENT_SCOPE) + endif() +endfunction() diff --git a/Tests/RunCMake/CPack/tests/LONG_FILENAMES/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/LONG_FILENAMES/ExpectedFiles.cmake new file mode 100644 index 0000000..631d957 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/LONG_FILENAMES/ExpectedFiles.cmake @@ -0,0 +1,3 @@ +set(EXPECTED_FILES_COUNT "1") +set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE) +set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/llllllllll_oooooooooo_nnnnnnnnnn_gggggggggg_ffffffffff_iiiiiiiiii_llllllllll_eeeeeeeeee_nnnnnnnnnn_aaaaaaaaaa_mmmmmmmmmm_eeeeeeeeee.txt") diff --git a/Tests/RunCMake/CPack/DEB/LONG_FILENAMES-VerifyResult.cmake b/Tests/RunCMake/CPack/tests/LONG_FILENAMES/VerifyResult.cmake index 0452343..0452343 100644 --- a/Tests/RunCMake/CPack/DEB/LONG_FILENAMES-VerifyResult.cmake +++ b/Tests/RunCMake/CPack/tests/LONG_FILENAMES/VerifyResult.cmake diff --git a/Tests/RunCMake/CPack/LONG_FILENAMES.cmake b/Tests/RunCMake/CPack/tests/LONG_FILENAMES/test.cmake index 3242aef..f235d47 100644 --- a/Tests/RunCMake/CPack/LONG_FILENAMES.cmake +++ b/Tests/RunCMake/CPack/tests/LONG_FILENAMES/test.cmake @@ -1,3 +1,8 @@ +if(GENERATOR_TYPE STREQUAL "DEB") + set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") + set(CPACK_DEBIAN_ARCHIVE_TYPE "gnutar") +endif() + set(LONG_FILENAME "${CMAKE_CURRENT_BINARY_DIR}/llllllllll_oooooooooo_nnnnnnnnnn_gggggggggg_ffffffffff_iiiiiiiiii_llllllllll_eeeeeeeeee_nnnnnnnnnn_aaaaaaaaaa_mmmmmmmmmm_eeeeeeeeee.txt") @@ -6,5 +11,3 @@ file(WRITE "long_filename_test") install(FILES ${LONG_FILENAME} DESTINATION foo) - -set(CPACK_PACKAGE_NAME "long_filenames") diff --git a/Tests/RunCMake/CPack/tests/MAIN_COMPONENT/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/MAIN_COMPONENT/ExpectedFiles.cmake new file mode 100644 index 0000000..6bfb0c1 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/MAIN_COMPONENT/ExpectedFiles.cmake @@ -0,0 +1,11 @@ +set(EXPECTED_FILES_COUNT "0") + +if(NOT RunCMake_SUBTEST_SUFFIX STREQUAL "invalid") + set(EXPECTED_FILES_COUNT "3") + set(EXPECTED_FILE_1 "main_component-0.1.1-1.*.rpm") + set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") + set(EXPECTED_FILE_2_COMPONENT "headers") + set(EXPECTED_FILE_CONTENT_2_LIST "/usr;/usr/bar;/usr/bar/CMakeLists.txt") + set(EXPECTED_FILE_3_COMPONENT "libs") + set(EXPECTED_FILE_CONTENT_3_LIST "/usr;/usr/bas;/usr/bas/CMakeLists.txt") +endif() diff --git a/Tests/RunCMake/CPack/RPM/MAIN_COMPONENT-invalid-stderr.txt b/Tests/RunCMake/CPack/tests/MAIN_COMPONENT/RPM-invalid-stderr.txt index 4d8ac6e..4d8ac6e 100644 --- a/Tests/RunCMake/CPack/RPM/MAIN_COMPONENT-invalid-stderr.txt +++ b/Tests/RunCMake/CPack/tests/MAIN_COMPONENT/RPM-invalid-stderr.txt diff --git a/Tests/RunCMake/CPack/MAIN_COMPONENT.cmake b/Tests/RunCMake/CPack/tests/MAIN_COMPONENT/test.cmake index 99c6cae..791c586 100644 --- a/Tests/RunCMake/CPack/MAIN_COMPONENT.cmake +++ b/Tests/RunCMake/CPack/tests/MAIN_COMPONENT/test.cmake @@ -1,5 +1,3 @@ -set(CPACK_RPM_COMPONENT_INSTALL "ON") - install(FILES CMakeLists.txt DESTINATION foo COMPONENT applications) install(FILES CMakeLists.txt DESTINATION bar COMPONENT headers) install(FILES CMakeLists.txt DESTINATION bas COMPONENT libs) @@ -10,5 +8,3 @@ else() set(CPACK_RPM_MAIN_COMPONENT "applications") set(CPACK_RPM_APPLICATIONS_FILE_NAME "RPM-DEFAULT") endif() - -set(CPACK_PACKAGE_NAME "main_component") diff --git a/Tests/RunCMake/CPack/tests/MINIMAL/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/MINIMAL/ExpectedFiles.cmake new file mode 100644 index 0000000..6142eb3 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/MINIMAL/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/MINIMAL.cmake b/Tests/RunCMake/CPack/tests/MINIMAL/test.cmake index f29ad2a..83ed0f2 100644 --- a/Tests/RunCMake/CPack/MINIMAL.cmake +++ b/Tests/RunCMake/CPack/tests/MINIMAL/test.cmake @@ -1,3 +1 @@ install(FILES CMakeLists.txt DESTINATION foo COMPONENT test) - -set(CPACK_PACKAGE_NAME "minimal") diff --git a/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/ExpectedFiles.cmake new file mode 100644 index 0000000..eed5b92 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/ExpectedFiles.cmake @@ -0,0 +1,6 @@ +set(EXPECTED_FILES_COUNT "0") + +if(NOT ${RunCMake_SUBTEST_SUFFIX} MATCHES "invalid") + set(EXPECTED_FILES_COUNT "1") + set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") +endif() diff --git a/Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-invalid-stderr.txt b/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/TGZ-invalid-stderr.txt index abf6d8c..abf6d8c 100644 --- a/Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-invalid-stderr.txt +++ b/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/TGZ-invalid-stderr.txt diff --git a/Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-VerifyResult.cmake b/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/VerifyResult.cmake index e9e65d6..e4f9618 100644 --- a/Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-VerifyResult.cmake +++ b/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/VerifyResult.cmake @@ -9,6 +9,4 @@ if(NOT ${RunCMake_SUBTEST_SUFFIX} MATCHES "invalid") if(NOT expected_value STREQUAL CHSUM_VALUE) message(FATAL_ERROR "Generated checksum is not valid! Expected [${expected_value}] Got [${CHSUM_VALUE}]") endif() -else() - message(${error}) endif() diff --git a/Tests/RunCMake/CPack/PACKAGE_CHECKSUM.cmake b/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/test.cmake index 5ca288c..0838063 100644 --- a/Tests/RunCMake/CPack/PACKAGE_CHECKSUM.cmake +++ b/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/test.cmake @@ -1,4 +1,3 @@ install(FILES CMakeLists.txt DESTINATION foo) -set(CPACK_PACKAGE_NAME "package_checksum") set(CPACK_PACKAGE_CHECKSUM ${RunCMake_SUBTEST_SUFFIX}) diff --git a/Tests/RunCMake/CPack/tests/PARTIALLY_RELOCATABLE_WARNING/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/PARTIALLY_RELOCATABLE_WARNING/ExpectedFiles.cmake new file mode 100644 index 0000000..ae58c4b --- /dev/null +++ b/Tests/RunCMake/CPack/tests/PARTIALLY_RELOCATABLE_WARNING/ExpectedFiles.cmake @@ -0,0 +1,2 @@ +set(EXPECTED_FILES_COUNT "1") +set(EXPECTED_FILE_CONTENT_1_LIST "/not_relocatable;/not_relocatable/CMakeLists.txt;/opt") diff --git a/Tests/RunCMake/CPack/RPM/PARTIALLY_RELOCATABLE_WARNING-stderr.txt b/Tests/RunCMake/CPack/tests/PARTIALLY_RELOCATABLE_WARNING/RPM-stderr.txt index 3b63d5b..3b63d5b 100644 --- a/Tests/RunCMake/CPack/RPM/PARTIALLY_RELOCATABLE_WARNING-stderr.txt +++ b/Tests/RunCMake/CPack/tests/PARTIALLY_RELOCATABLE_WARNING/RPM-stderr.txt diff --git a/Tests/RunCMake/CPack/PARTIALLY_RELOCATABLE_WARNING.cmake b/Tests/RunCMake/CPack/tests/PARTIALLY_RELOCATABLE_WARNING/test.cmake index 31e729b..4698fb3 100644 --- a/Tests/RunCMake/CPack/PARTIALLY_RELOCATABLE_WARNING.cmake +++ b/Tests/RunCMake/CPack/tests/PARTIALLY_RELOCATABLE_WARNING/test.cmake @@ -2,5 +2,3 @@ install(FILES CMakeLists.txt DESTINATION /not_relocatable COMPONENT static) set(CPACK_PACKAGE_RELOCATABLE TRUE) set(CPACK_PACKAGING_INSTALL_PREFIX "/opt") - -set(CPACK_RPM_COMPONENT_INSTALL ON) diff --git a/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/ExpectedFiles.cmake new file mode 100644 index 0000000..9bdb176 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/ExpectedFiles.cmake @@ -0,0 +1,8 @@ +set(EXPECTED_FILES_COUNT "3") +set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE) +set(EXPECTED_FILE_1_COMPONENT "pkg_1") +set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") +set(EXPECTED_FILE_2_NAME "second") +set(EXPECTED_FILE_CONTENT_2_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") +set(EXPECTED_FILE_3_COMPONENT "pkg_3") +set(EXPECTED_FILE_CONTENT_3_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt") diff --git a/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/VerifyResult.cmake new file mode 100644 index 0000000..18ef63c --- /dev/null +++ b/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/VerifyResult.cmake @@ -0,0 +1,26 @@ +function(checkPackageInfo_ TYPE FILE REGEX) + getPackageInfo("${FILE}" "FILE_INFO_") + if(NOT FILE_INFO_ MATCHES "${REGEX}") + message(FATAL_ERROR "Unexpected ${TYPE} in '${FILE}'; file info: '${FILE_INFO_}'") + endif() +endfunction() + +if(GENERATOR_TYPE STREQUAL "DEB") + set(name_ "Package") + set(group_ "Section") +elseif(GENERATOR_TYPE STREQUAL "RPM") + set(name_ "Name") + set(group_ "Group") +endif() + +set(whitespaces_ "[\t\n\r ]*") + +# check package name +checkPackageInfo_("name" "${FOUND_FILE_1}" ".*${name_}${whitespaces_}:${whitespaces_}per_component_fields-pkg_1") +checkPackageInfo_("name" "${FOUND_FILE_2}" ".*${name_}${whitespaces_}:${whitespaces_}second") +checkPackageInfo_("name" "${FOUND_FILE_3}" ".*${name_}${whitespaces_}:${whitespaces_}per_component_fields-pkg_3") + +# check package group +checkPackageInfo_("group" "${FOUND_FILE_1}" ".*${group_}${whitespaces_}:${whitespaces_}default") +checkPackageInfo_("group" "${FOUND_FILE_2}" ".*${group_}${whitespaces_}:${whitespaces_}second_group") +checkPackageInfo_("group" "${FOUND_FILE_3}" ".*${group_}${whitespaces_}:${whitespaces_}default") diff --git a/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/test.cmake b/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/test.cmake new file mode 100644 index 0000000..8719c0b --- /dev/null +++ b/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/test.cmake @@ -0,0 +1,18 @@ +if(GENERATOR_TYPE STREQUAL "DEB" OR GENERATOR_TYPE STREQUAL "RPM") + if(GENERATOR_TYPE STREQUAL "DEB") + set(generator_type_suffix_ "IAN") # not entirely compatible... + set(group_ "SECTION") + else() + set(group_ "GROUP") + endif() + + set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_FILE_NAME "${GENERATOR_TYPE}-DEFAULT") + + set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_PACKAGE_${group_} "default") + set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_PKG_2_PACKAGE_NAME "second") + set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_PKG_2_PACKAGE_${group_} "second_group") +endif() + +install(FILES CMakeLists.txt DESTINATION foo COMPONENT pkg_1) +install(FILES CMakeLists.txt DESTINATION foo COMPONENT pkg_2) +install(FILES CMakeLists.txt DESTINATION foo COMPONENT pkg_3) diff --git a/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/ExpectedFiles.cmake index dc49343..ca866ea 100644 --- a/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/ExpectedFiles.cmake @@ -1,29 +1,29 @@ set(whitespaces_ "[\t\n\r ]*") - set(EXPECTED_FILES_COUNT "0") +set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE) if(RunCMake_SUBTEST_SUFFIX STREQUAL "valid" OR RunCMake_SUBTEST_SUFFIX STREQUAL "no_debuginfo") set(EXPECTED_FILES_COUNT "4") set(EXPECTED_FILE_1 "single_debuginfo-0.1.1-1.*.rpm") - set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/test_prog$") + set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/test_prog") set(EXPECTED_FILE_2 "single_debuginfo*-headers.rpm") - set(EXPECTED_FILE_CONTENT_2 "^/usr/bar${whitespaces_}/usr/bar/CMakeLists.txt$") + set(EXPECTED_FILE_CONTENT_2_LIST "/usr;/usr/bar;/usr/bar/CMakeLists.txt") set(EXPECTED_FILE_3 "single_debuginfo*-libs.rpm") - set(EXPECTED_FILE_CONTENT_3 "^/usr/bas${whitespaces_}/usr/bas/libtest_lib.so$") + set(EXPECTED_FILE_CONTENT_3_LIST "/usr;/usr/bas;/usr/bas/libtest_lib.so") - set(EXPECTED_FILE_4 "single_debuginfo-debuginfo*.rpm") + set(EXPECTED_FILE_4_COMPONENT "debuginfo") set(EXPECTED_FILE_CONTENT_4 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp${whitespaces_}/src/src_1/test_lib.cpp.*") elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "one_component" OR RunCMake_SUBTEST_SUFFIX STREQUAL "one_component_no_debuginfo") set(EXPECTED_FILES_COUNT "2") set(EXPECTED_FILE_1 "single_debuginfo-0*-applications.rpm") - set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/test_prog$") + set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/test_prog") set(EXPECTED_FILE_2 "single_debuginfo-applications-debuginfo*.rpm") set(EXPECTED_FILE_CONTENT_2 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp.*") elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "one_component_main" OR RunCMake_SUBTEST_SUFFIX STREQUAL "no_components") set(EXPECTED_FILES_COUNT "2") set(EXPECTED_FILE_1 "single_debuginfo-0*.rpm") - set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/test_prog$") + set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/test_prog") set(EXPECTED_FILE_2 "single_debuginfo-debuginfo*.rpm") set(EXPECTED_FILE_CONTENT_2 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp.*") diff --git a/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-no_main_component-stderr.txt b/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/RPM-no_main_component-stderr.txt index 454283c..454283c 100644 --- a/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-no_main_component-stderr.txt +++ b/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/RPM-no_main_component-stderr.txt diff --git a/Tests/RunCMake/CPack/SINGLE_DEBUGINFO.cmake b/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/test.cmake index ae4995e..60e9038 100644 --- a/Tests/RunCMake/CPack/SINGLE_DEBUGINFO.cmake +++ b/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/test.cmake @@ -52,5 +52,3 @@ if(RunCMake_SUBTEST_SUFFIX STREQUAL "valid" endif() set(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX "/src") - -set(CPACK_PACKAGE_NAME "single_debuginfo") diff --git a/Tests/RunCMake/CPack/tests/SOURCE_PACKAGE/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/SOURCE_PACKAGE/ExpectedFiles.cmake new file mode 100644 index 0000000..0a3e426 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/SOURCE_PACKAGE/ExpectedFiles.cmake @@ -0,0 +1,2 @@ +set(EXPECTED_FILES_COUNT "1") +set(EXPECTED_FILE_CONTENT_1_LIST "source_package-0.1.1.tar.gz;source_package.spec") diff --git a/Tests/RunCMake/CPack/RPM/SOURCE_PACKAGE-VerifyResult.cmake b/Tests/RunCMake/CPack/tests/SOURCE_PACKAGE/VerifyResult.cmake index a84e296..bc54d79 100644 --- a/Tests/RunCMake/CPack/RPM/SOURCE_PACKAGE-VerifyResult.cmake +++ b/Tests/RunCMake/CPack/tests/SOURCE_PACKAGE/VerifyResult.cmake @@ -1,3 +1,5 @@ +set(whitespaces_ "[\t\n\r ]*") + file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_rpm") file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/BUILD") file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/BUILDROOT") diff --git a/Tests/RunCMake/CPack/SOURCE_PACKAGE.cmake b/Tests/RunCMake/CPack/tests/SOURCE_PACKAGE/test.cmake index 946439d..359b98f 100644 --- a/Tests/RunCMake/CPack/SOURCE_PACKAGE.cmake +++ b/Tests/RunCMake/CPack/tests/SOURCE_PACKAGE/test.cmake @@ -5,5 +5,3 @@ add_executable(test_prog "${CMAKE_CURRENT_BINARY_DIR}/main.cpp") install(TARGETS test_prog DESTINATION foo COMPONENT applications) set(CPACK_RPM_FILE_NAME "RPM-DEFAULT") - -set(CPACK_PACKAGE_NAME "source_package") diff --git a/Tests/RunCMake/CPack/tests/SUGGESTS/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/SUGGESTS/ExpectedFiles.cmake new file mode 100644 index 0000000..6142eb3 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/SUGGESTS/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/SUGGESTS/RPM-stderr.txt b/Tests/RunCMake/CPack/tests/SUGGESTS/RPM-stderr.txt new file mode 100644 index 0000000..feb296c --- /dev/null +++ b/Tests/RunCMake/CPack/tests/SUGGESTS/RPM-stderr.txt @@ -0,0 +1 @@ +^(.*CPackRPM:Warning: SUGGESTS not supported in provided rpmbuild.*)?CPackRPM: Will use GENERATED spec file: (/[^/]*)*/Tests/RunCMake/RPM/CPack/[^-]*-build/_CPack_Packages/.*/RPM/SPECS/[^\.]*\.spec$ diff --git a/Tests/RunCMake/CPack/RPM/RPM_SUGGESTS-VerifyResult.cmake b/Tests/RunCMake/CPack/tests/SUGGESTS/VerifyResult.cmake index 32cc6d1..32cc6d1 100644 --- a/Tests/RunCMake/CPack/RPM/RPM_SUGGESTS-VerifyResult.cmake +++ b/Tests/RunCMake/CPack/tests/SUGGESTS/VerifyResult.cmake diff --git a/Tests/RunCMake/CPack/RPM_SUGGESTS.cmake b/Tests/RunCMake/CPack/tests/SUGGESTS/test.cmake index e6e0c1f..dc90ae8 100644 --- a/Tests/RunCMake/CPack/RPM_SUGGESTS.cmake +++ b/Tests/RunCMake/CPack/tests/SUGGESTS/test.cmake @@ -1,4 +1,3 @@ install(FILES CMakeLists.txt DESTINATION foo) set(CPACK_RPM_PACKAGE_SUGGESTS "libsuggested") -set(CPACK_PACKAGE_NAME "rpm_suggests") diff --git a/Tests/RunCMake/ClangTidy/C-bad-Build-result.txt b/Tests/RunCMake/ClangTidy/C-bad-Build-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/ClangTidy/C-bad-Build-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/ClangTidy/C-bad-Build-stdout.txt b/Tests/RunCMake/ClangTidy/C-bad-Build-stdout.txt new file mode 100644 index 0000000..2370ce1 --- /dev/null +++ b/Tests/RunCMake/ClangTidy/C-bad-Build-stdout.txt @@ -0,0 +1,2 @@ +stdout from bad command line arg '-bad' +stderr from bad command line arg '-bad' diff --git a/Tests/RunCMake/ClangTidy/C-bad.cmake b/Tests/RunCMake/ClangTidy/C-bad.cmake new file mode 100644 index 0000000..aa54c08 --- /dev/null +++ b/Tests/RunCMake/ClangTidy/C-bad.cmake @@ -0,0 +1,3 @@ +enable_language(C) +set(CMAKE_C_CLANG_TIDY "${PSEUDO_TIDY}" -bad) +add_executable(main main.c) diff --git a/Tests/RunCMake/ClangTidy/RunCMakeTest.cmake b/Tests/RunCMake/ClangTidy/RunCMakeTest.cmake index 27cd922..2f41e50 100644 --- a/Tests/RunCMake/ClangTidy/RunCMakeTest.cmake +++ b/Tests/RunCMake/ClangTidy/RunCMakeTest.cmake @@ -20,3 +20,4 @@ if (NOT RunCMake_GENERATOR STREQUAL "Watcom WMake") run_tidy(C-launch) run_tidy(CXX-launch) endif() +run_tidy(C-bad) diff --git a/Tests/RunCMake/Configure/RemoveCache-stdout.txt b/Tests/RunCMake/Configure/RemoveCache-stdout.txt new file mode 100644 index 0000000..73e7e5d --- /dev/null +++ b/Tests/RunCMake/Configure/RemoveCache-stdout.txt @@ -0,0 +1 @@ +-- The C compiler identification is diff --git a/Tests/RunCMake/Configure/RemoveCache.cmake b/Tests/RunCMake/Configure/RemoveCache.cmake new file mode 100644 index 0000000..304918f --- /dev/null +++ b/Tests/RunCMake/Configure/RemoveCache.cmake @@ -0,0 +1,17 @@ +enable_language(C) + +set(vars + CMAKE_EXECUTABLE_FORMAT + ) + +if(CMAKE_HOST_UNIX) + list(APPEND vars + CMAKE_UNAME + ) +endif() + +foreach(v IN LISTS vars) + if(NOT DEFINED ${v}) + message(SEND_ERROR "Variable '${v}' is not set!") + endif() +endforeach() diff --git a/Tests/RunCMake/Configure/RunCMakeTest.cmake b/Tests/RunCMake/Configure/RunCMakeTest.cmake index 91adb4e..4a135be 100644 --- a/Tests/RunCMake/Configure/RunCMakeTest.cmake +++ b/Tests/RunCMake/Configure/RunCMakeTest.cmake @@ -24,3 +24,12 @@ file(WRITE "${depend}" "2") run_cmake_command(RerunCMake-build2 ${CMAKE_COMMAND} --build .) unset(RunCMake_TEST_BINARY_DIR) unset(RunCMake_TEST_NO_CLEAN) + +# Use a single build tree for a few tests without cleaning. +set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/RemoveCache-build) +set(RunCMake_TEST_NO_CLEAN 1) +file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") +file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") +run_cmake(RemoveCache) +file(REMOVE "${RunCMake_TEST_BINARY_DIR}/CMakeCache.txt") +run_cmake(RemoveCache) diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake index cc2cc2e..22d8164 100644 --- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake +++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake @@ -1,2 +1,3 @@ include(RunCMake) run_cmake(VsConfigurationType) +run_cmake(VsTargetsFileReferences) diff --git a/Tests/RunCMake/VS10Project/VsTargetsFileReferences-check.cmake b/Tests/RunCMake/VS10Project/VsTargetsFileReferences-check.cmake new file mode 100644 index 0000000..3d01c2c --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsTargetsFileReferences-check.cmake @@ -0,0 +1,45 @@ +set(files foo.vcxproj bar.vcxproj baz.vcxproj) + +foreach(file ${files}) + set(vsProjectFile ${RunCMake_TEST_BINARY_DIR}/${file}) + + if(NOT EXISTS "${vsProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${vsProjectFile} does not exist.") + return() + endif() + + set(waldoFound FALSE) + set(xyzzyFound FALSE) + file(STRINGS "${vsProjectFile}" lines) + foreach(line IN LISTS lines) + if(line MATCHES "^ *<Import Project=.*/>$") + if(line MATCHES "^.*waldo.targets.*$") + set(waldoFound TRUE) + message(STATUS "${file} is importing waldo.targets") + elseif(line MATCHES "^.*xyzzy.targets.*$") + set(xyzzyFound TRUE) + message(STATUS "${file} is importing xyzzy.targets") + endif() + endif() + endforeach() + + if("${file}" STREQUAL "foo.vcxproj") + if(NOT xyzzyFound) + set(RunCMake_TEST_FAILED "xyzzy.targets not imported from ${file}") + return() + endif() + if(waldoFound) + set(RunCMake_TEST_FAILED "waldo.targets imported from ${file}") + return() + endif() + else() + if(NOT xyzzyFound) + set(RunCMake_TEST_FAILED "xyzzy.targets not imported from ${file}") + return() + endif() + if(NOT waldoFound) + set(RunCMake_TEST_FAILED "waldo.targets not imported from ${file}") + return() + endif() + endif() +endforeach() diff --git a/Tests/RunCMake/VS10Project/VsTargetsFileReferences.cmake b/Tests/RunCMake/VS10Project/VsTargetsFileReferences.cmake new file mode 100644 index 0000000..5ca4f1f --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsTargetsFileReferences.cmake @@ -0,0 +1,9 @@ +enable_language(CXX) +add_library(foo foo.cpp) +target_link_libraries(foo ${CMAKE_BINARY_DIR}/xyzzy.targets) + +add_library(bar bar.cpp) +target_link_libraries(bar foo ${CMAKE_BINARY_DIR}/waldo.targets) + +add_executable(baz baz.cpp) +target_link_libraries(baz bar) diff --git a/Tests/RunCMake/VS10Project/bar.cpp b/Tests/RunCMake/VS10Project/bar.cpp new file mode 100644 index 0000000..b72a1a5 --- /dev/null +++ b/Tests/RunCMake/VS10Project/bar.cpp @@ -0,0 +1,3 @@ +void bar() +{ +} diff --git a/Tests/RunCMake/VS10Project/baz.cpp b/Tests/RunCMake/VS10Project/baz.cpp new file mode 100644 index 0000000..d5d334a --- /dev/null +++ b/Tests/RunCMake/VS10Project/baz.cpp @@ -0,0 +1,3 @@ +void baz() +{ +} diff --git a/Tests/RunCMake/ctest_memcheck/DummyPurify-stdout.txt b/Tests/RunCMake/ctest_memcheck/DummyPurify-stdout.txt index dabb004..69ab584 100644 --- a/Tests/RunCMake/ctest_memcheck/DummyPurify-stdout.txt +++ b/Tests/RunCMake/ctest_memcheck/DummyPurify-stdout.txt @@ -2,5 +2,7 @@ 100% tests passed, 0 tests failed out of 1 .* --- Processing memory checking output:( ) +-- Processing memory checking output: +MemCheck log files can be found here:.*corresponds to test number. +.*MemoryChecker.*log Memory checking results: diff --git a/Tests/RunCMake/ctest_memcheck/DummyValgrind-stdout.txt b/Tests/RunCMake/ctest_memcheck/DummyValgrind-stdout.txt index dabb004..69ab584 100644 --- a/Tests/RunCMake/ctest_memcheck/DummyValgrind-stdout.txt +++ b/Tests/RunCMake/ctest_memcheck/DummyValgrind-stdout.txt @@ -2,5 +2,7 @@ 100% tests passed, 0 tests failed out of 1 .* --- Processing memory checking output:( ) +-- Processing memory checking output: +MemCheck log files can be found here:.*corresponds to test number. +.*MemoryChecker.*log Memory checking results: diff --git a/Tests/RunCMake/ctest_memcheck/DummyValgrindCustomOptions-stdout.txt b/Tests/RunCMake/ctest_memcheck/DummyValgrindCustomOptions-stdout.txt index dabb004..69ab584 100644 --- a/Tests/RunCMake/ctest_memcheck/DummyValgrindCustomOptions-stdout.txt +++ b/Tests/RunCMake/ctest_memcheck/DummyValgrindCustomOptions-stdout.txt @@ -2,5 +2,7 @@ 100% tests passed, 0 tests failed out of 1 .* --- Processing memory checking output:( ) +-- Processing memory checking output: +MemCheck log files can be found here:.*corresponds to test number. +.*MemoryChecker.*log Memory checking results: diff --git a/Tests/RunCMake/ctest_memcheck/DummyValgrindFailPost-stdout.txt b/Tests/RunCMake/ctest_memcheck/DummyValgrindFailPost-stdout.txt index dabb004..69ab584 100644 --- a/Tests/RunCMake/ctest_memcheck/DummyValgrindFailPost-stdout.txt +++ b/Tests/RunCMake/ctest_memcheck/DummyValgrindFailPost-stdout.txt @@ -2,5 +2,7 @@ 100% tests passed, 0 tests failed out of 1 .* --- Processing memory checking output:( ) +-- Processing memory checking output: +MemCheck log files can be found here:.*corresponds to test number. +.*MemoryChecker.*log Memory checking results: diff --git a/Tests/RunCMake/ctest_memcheck/DummyValgrindIgnoreMemcheck-stdout.txt b/Tests/RunCMake/ctest_memcheck/DummyValgrindIgnoreMemcheck-stdout.txt index 5a5675c..88b4788 100644 --- a/Tests/RunCMake/ctest_memcheck/DummyValgrindIgnoreMemcheck-stdout.txt +++ b/Tests/RunCMake/ctest_memcheck/DummyValgrindIgnoreMemcheck-stdout.txt @@ -3,5 +3,7 @@ 100% tests passed, 0 tests failed out of 1 .* --- Processing memory checking output:( ) +-- Processing memory checking output: +MemCheck log files can be found here:.*corresponds to test number. +.*MemoryChecker.*log Memory checking results: diff --git a/Tests/RunCMake/ctest_memcheck/DummyValgrindNoDefects-stdout.txt b/Tests/RunCMake/ctest_memcheck/DummyValgrindNoDefects-stdout.txt index dabb004..69ab584 100644 --- a/Tests/RunCMake/ctest_memcheck/DummyValgrindNoDefects-stdout.txt +++ b/Tests/RunCMake/ctest_memcheck/DummyValgrindNoDefects-stdout.txt @@ -2,5 +2,7 @@ 100% tests passed, 0 tests failed out of 1 .* --- Processing memory checking output:( ) +-- Processing memory checking output: +MemCheck log files can be found here:.*corresponds to test number. +.*MemoryChecker.*log Memory checking results: diff --git a/Tests/RunCMake/ctest_memcheck/DummyValgrindPrePost-stdout.txt b/Tests/RunCMake/ctest_memcheck/DummyValgrindPrePost-stdout.txt index dabb004..69ab584 100644 --- a/Tests/RunCMake/ctest_memcheck/DummyValgrindPrePost-stdout.txt +++ b/Tests/RunCMake/ctest_memcheck/DummyValgrindPrePost-stdout.txt @@ -2,5 +2,7 @@ 100% tests passed, 0 tests failed out of 1 .* --- Processing memory checking output:( ) +-- Processing memory checking output: +MemCheck log files can be found here:.*corresponds to test number. +.*MemoryChecker.*log Memory checking results: diff --git a/Tests/RunCMake/pseudo_iwyu.c b/Tests/RunCMake/pseudo_iwyu.c index 1e25de7..c761741 100644 --- a/Tests/RunCMake/pseudo_iwyu.c +++ b/Tests/RunCMake/pseudo_iwyu.c @@ -3,5 +3,6 @@ int main(void) { fprintf(stderr, "should add these lines:\n#include <...>\n"); - return 0; + /* include-what-you-use always returns failure */ + return 1; } diff --git a/Tests/RunCMake/pseudo_tidy.c b/Tests/RunCMake/pseudo_tidy.c index c950d03..2feeb0f 100644 --- a/Tests/RunCMake/pseudo_tidy.c +++ b/Tests/RunCMake/pseudo_tidy.c @@ -1,9 +1,15 @@ #include <stdio.h> +#include <string.h> int main(int argc, char* argv[]) { int i; for (i = 1; i < argc; ++i) { + if (strcmp(argv[i], "-bad") == 0) { + fprintf(stdout, "stdout from bad command line arg '-bad'\n"); + fprintf(stderr, "stderr from bad command line arg '-bad'\n"); + return 1; + } if (argv[i][0] != '-') { fprintf(stdout, "%s:0:0: warning: message [checker]\n", argv[i]); break; diff --git a/Utilities/Release/linux64_release.cmake b/Utilities/Release/linux64_release.cmake index b9447ca..feba2a5 100644 --- a/Utilities/Release/linux64_release.cmake +++ b/Utilities/Release/linux64_release.cmake @@ -29,9 +29,9 @@ CURSES_LIBRARY:FILEPATH=/home/kitware/ncurses-5.9/lib/libncurses.a CURSES_INCLUDE_PATH:PATH=/home/kitware/ncurses-5.9/include FORM_LIBRARY:FILEPATH=/home/kitware/ncurses-5.9/lib/libform.a CMAKE_USE_OPENSSL:BOOL=ON -OPENSSL_CRYPTO_LIBRARY:FILEPATH=/home/kitware/openssl-1.0.2h/lib/libcrypto.a -OPENSSL_INCLUDE_DIR:PATH=/home/kitware/openssl-1.0.2h/include -OPENSSL_SSL_LIBRARY:FILEPATH=/home/kitware/openssl-1.0.2h/lib/libssl.a +OPENSSL_CRYPTO_LIBRARY:FILEPATH=/home/kitware/openssl-1.0.2j/lib/libcrypto.a +OPENSSL_INCLUDE_DIR:PATH=/home/kitware/openssl-1.0.2j/include +OPENSSL_SSL_LIBRARY:FILEPATH=/home/kitware/openssl-1.0.2j/lib/libssl.a PYTHON_EXECUTABLE:FILEPATH=/usr/bin/python3 CPACK_SYSTEM_NAME:STRING=Linux-x86_64 BUILD_QtDialog:BOOL:=TRUE diff --git a/Utilities/Scripts/update-librhash.bash b/Utilities/Scripts/update-librhash.bash index 2f67ea2..009ce32 100755 --- a/Utilities/Scripts/update-librhash.bash +++ b/Utilities/Scripts/update-librhash.bash @@ -27,6 +27,8 @@ readonly paths=" librhash/sha1.h librhash/sha256.c librhash/sha256.h + librhash/sha3.c + librhash/sha3.h librhash/sha512.c librhash/sha512.h librhash/ustd.h diff --git a/Utilities/cmlibarchive/libarchive/CMakeLists.txt b/Utilities/cmlibarchive/libarchive/CMakeLists.txt index 4eeb5e3..eaa7b20 100644 --- a/Utilities/cmlibarchive/libarchive/CMakeLists.txt +++ b/Utilities/cmlibarchive/libarchive/CMakeLists.txt @@ -38,6 +38,8 @@ SET(libarchive_SOURCES archive_hmac.c archive_hmac_private.h archive_match.c + archive_openssl_evp_private.h + archive_openssl_hmac_private.h archive_options.c archive_options_private.h archive_pack_dev.h diff --git a/Utilities/cmlibarchive/libarchive/archive_cryptor.c b/Utilities/cmlibarchive/libarchive/archive_cryptor.c index 0be30c6..2a51dfe 100644 --- a/Utilities/cmlibarchive/libarchive/archive_cryptor.c +++ b/Utilities/cmlibarchive/libarchive/archive_cryptor.c @@ -302,6 +302,7 @@ aes_ctr_release(archive_crypto_ctx *ctx) static int aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len) { + ctx->ctx = EVP_CIPHER_CTX_new(); switch (key_len) { case 16: ctx->type = EVP_aes_128_ecb(); break; @@ -314,7 +315,7 @@ aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len) memcpy(ctx->key, key, key_len); memset(ctx->nonce, 0, sizeof(ctx->nonce)); ctx->encr_pos = AES_BLOCK_SIZE; - EVP_CIPHER_CTX_init(&ctx->ctx); + EVP_CIPHER_CTX_init(ctx->ctx); return 0; } @@ -324,10 +325,10 @@ aes_ctr_encrypt_counter(archive_crypto_ctx *ctx) int outl = 0; int r; - r = EVP_EncryptInit_ex(&ctx->ctx, ctx->type, NULL, ctx->key, NULL); + r = EVP_EncryptInit_ex(ctx->ctx, ctx->type, NULL, ctx->key, NULL); if (r == 0) return -1; - r = EVP_EncryptUpdate(&ctx->ctx, ctx->encr_buf, &outl, ctx->nonce, + r = EVP_EncryptUpdate(ctx->ctx, ctx->encr_buf, &outl, ctx->nonce, AES_BLOCK_SIZE); if (r == 0 || outl != AES_BLOCK_SIZE) return -1; @@ -337,7 +338,7 @@ aes_ctr_encrypt_counter(archive_crypto_ctx *ctx) static int aes_ctr_release(archive_crypto_ctx *ctx) { - EVP_CIPHER_CTX_cleanup(&ctx->ctx); + EVP_CIPHER_CTX_free(ctx->ctx); memset(ctx->key, 0, ctx->key_len); memset(ctx->nonce, 0, sizeof(ctx->nonce)); return 0; diff --git a/Utilities/cmlibarchive/libarchive/archive_cryptor_private.h b/Utilities/cmlibarchive/libarchive/archive_cryptor_private.h index 37eaad3..0ca544b 100644 --- a/Utilities/cmlibarchive/libarchive/archive_cryptor_private.h +++ b/Utilities/cmlibarchive/libarchive/archive_cryptor_private.h @@ -99,12 +99,12 @@ typedef struct { } archive_crypto_ctx; #elif defined(HAVE_LIBCRYPTO) -#include <openssl/evp.h> +#include "archive_openssl_evp_private.h" #define AES_BLOCK_SIZE 16 #define AES_MAX_KEY_SIZE 32 typedef struct { - EVP_CIPHER_CTX ctx; + EVP_CIPHER_CTX *ctx; const EVP_CIPHER *type; uint8_t key[AES_MAX_KEY_SIZE]; unsigned key_len; diff --git a/Utilities/cmlibarchive/libarchive/archive_digest.c b/Utilities/cmlibarchive/libarchive/archive_digest.c index f009d31..4153923 100644 --- a/Utilities/cmlibarchive/libarchive/archive_digest.c +++ b/Utilities/cmlibarchive/libarchive/archive_digest.c @@ -207,7 +207,9 @@ __archive_nettle_md5final(archive_md5_ctx *ctx, void *md) static int __archive_openssl_md5init(archive_md5_ctx *ctx) { - EVP_DigestInit(ctx, EVP_md5()); + if ((*ctx = EVP_MD_CTX_new()) == NULL) + return (ARCHIVE_FAILED); + EVP_DigestInit(*ctx, EVP_md5()); return (ARCHIVE_OK); } @@ -215,7 +217,7 @@ static int __archive_openssl_md5update(archive_md5_ctx *ctx, const void *indata, size_t insize) { - EVP_DigestUpdate(ctx, indata, insize); + EVP_DigestUpdate(*ctx, indata, insize); return (ARCHIVE_OK); } @@ -226,8 +228,11 @@ __archive_openssl_md5final(archive_md5_ctx *ctx, void *md) * this is meant to cope with that. Real fix is probably to fix * archive_write_set_format_xar.c */ - if (ctx->digest) - EVP_DigestFinal(ctx, md, NULL); + if (*ctx) { + EVP_DigestFinal(*ctx, md, NULL); + EVP_MD_CTX_free(*ctx); + *ctx = NULL; + } return (ARCHIVE_OK); } @@ -359,7 +364,9 @@ __archive_nettle_ripemd160final(archive_rmd160_ctx *ctx, void *md) static int __archive_openssl_ripemd160init(archive_rmd160_ctx *ctx) { - EVP_DigestInit(ctx, EVP_ripemd160()); + if ((*ctx = EVP_MD_CTX_new()) == NULL) + return (ARCHIVE_FAILED); + EVP_DigestInit(*ctx, EVP_ripemd160()); return (ARCHIVE_OK); } @@ -367,14 +374,18 @@ static int __archive_openssl_ripemd160update(archive_rmd160_ctx *ctx, const void *indata, size_t insize) { - EVP_DigestUpdate(ctx, indata, insize); + EVP_DigestUpdate(*ctx, indata, insize); return (ARCHIVE_OK); } static int __archive_openssl_ripemd160final(archive_rmd160_ctx *ctx, void *md) { - EVP_DigestFinal(ctx, md, NULL); + if (*ctx) { + EVP_DigestFinal(*ctx, md, NULL); + EVP_MD_CTX_free(*ctx); + *ctx = NULL; + } return (ARCHIVE_OK); } @@ -509,7 +520,9 @@ __archive_nettle_sha1final(archive_sha1_ctx *ctx, void *md) static int __archive_openssl_sha1init(archive_sha1_ctx *ctx) { - EVP_DigestInit(ctx, EVP_sha1()); + if ((*ctx = EVP_MD_CTX_new()) == NULL) + return (ARCHIVE_FAILED); + EVP_DigestInit(*ctx, EVP_sha1()); return (ARCHIVE_OK); } @@ -517,7 +530,7 @@ static int __archive_openssl_sha1update(archive_sha1_ctx *ctx, const void *indata, size_t insize) { - EVP_DigestUpdate(ctx, indata, insize); + EVP_DigestUpdate(*ctx, indata, insize); return (ARCHIVE_OK); } @@ -528,8 +541,11 @@ __archive_openssl_sha1final(archive_sha1_ctx *ctx, void *md) * this is meant to cope with that. Real fix is probably to fix * archive_write_set_format_xar.c */ - if (ctx->digest) - EVP_DigestFinal(ctx, md, NULL); + if (*ctx) { + EVP_DigestFinal(*ctx, md, NULL); + EVP_MD_CTX_free(*ctx); + *ctx = NULL; + } return (ARCHIVE_OK); } @@ -733,7 +749,9 @@ __archive_nettle_sha256final(archive_sha256_ctx *ctx, void *md) static int __archive_openssl_sha256init(archive_sha256_ctx *ctx) { - EVP_DigestInit(ctx, EVP_sha256()); + if ((*ctx = EVP_MD_CTX_new()) == NULL) + return (ARCHIVE_FAILED); + EVP_DigestInit(*ctx, EVP_sha256()); return (ARCHIVE_OK); } @@ -741,14 +759,18 @@ static int __archive_openssl_sha256update(archive_sha256_ctx *ctx, const void *indata, size_t insize) { - EVP_DigestUpdate(ctx, indata, insize); + EVP_DigestUpdate(*ctx, indata, insize); return (ARCHIVE_OK); } static int __archive_openssl_sha256final(archive_sha256_ctx *ctx, void *md) { - EVP_DigestFinal(ctx, md, NULL); + if (*ctx) { + EVP_DigestFinal(*ctx, md, NULL); + EVP_MD_CTX_free(*ctx); + *ctx = NULL; + } return (ARCHIVE_OK); } @@ -928,7 +950,9 @@ __archive_nettle_sha384final(archive_sha384_ctx *ctx, void *md) static int __archive_openssl_sha384init(archive_sha384_ctx *ctx) { - EVP_DigestInit(ctx, EVP_sha384()); + if ((*ctx = EVP_MD_CTX_new()) == NULL) + return (ARCHIVE_FAILED); + EVP_DigestInit(*ctx, EVP_sha384()); return (ARCHIVE_OK); } @@ -936,14 +960,18 @@ static int __archive_openssl_sha384update(archive_sha384_ctx *ctx, const void *indata, size_t insize) { - EVP_DigestUpdate(ctx, indata, insize); + EVP_DigestUpdate(*ctx, indata, insize); return (ARCHIVE_OK); } static int __archive_openssl_sha384final(archive_sha384_ctx *ctx, void *md) { - EVP_DigestFinal(ctx, md, NULL); + if (*ctx) { + EVP_DigestFinal(*ctx, md, NULL); + EVP_MD_CTX_free(*ctx); + *ctx = NULL; + } return (ARCHIVE_OK); } @@ -1147,7 +1175,9 @@ __archive_nettle_sha512final(archive_sha512_ctx *ctx, void *md) static int __archive_openssl_sha512init(archive_sha512_ctx *ctx) { - EVP_DigestInit(ctx, EVP_sha512()); + if ((*ctx = EVP_MD_CTX_new()) == NULL) + return (ARCHIVE_FAILED); + EVP_DigestInit(*ctx, EVP_sha512()); return (ARCHIVE_OK); } @@ -1155,14 +1185,18 @@ static int __archive_openssl_sha512update(archive_sha512_ctx *ctx, const void *indata, size_t insize) { - EVP_DigestUpdate(ctx, indata, insize); + EVP_DigestUpdate(*ctx, indata, insize); return (ARCHIVE_OK); } static int __archive_openssl_sha512final(archive_sha512_ctx *ctx, void *md) { - EVP_DigestFinal(ctx, md, NULL); + if (*ctx) { + EVP_DigestFinal(*ctx, md, NULL); + EVP_MD_CTX_free(*ctx); + *ctx = NULL; + } return (ARCHIVE_OK); } diff --git a/Utilities/cmlibarchive/libarchive/archive_digest_private.h b/Utilities/cmlibarchive/libarchive/archive_digest_private.h index 77fad58..b58ffb3 100644 --- a/Utilities/cmlibarchive/libarchive/archive_digest_private.h +++ b/Utilities/cmlibarchive/libarchive/archive_digest_private.h @@ -134,7 +134,7 @@ defined(ARCHIVE_CRYPTO_SHA384_OPENSSL) ||\ defined(ARCHIVE_CRYPTO_SHA512_OPENSSL) #define ARCHIVE_CRYPTO_OPENSSL 1 -#include <openssl/evp.h> +#include "archive_openssl_evp_private.h" #endif /* Windows crypto headers */ @@ -161,7 +161,7 @@ typedef CC_MD5_CTX archive_md5_ctx; #elif defined(ARCHIVE_CRYPTO_MD5_NETTLE) typedef struct md5_ctx archive_md5_ctx; #elif defined(ARCHIVE_CRYPTO_MD5_OPENSSL) -typedef EVP_MD_CTX archive_md5_ctx; +typedef EVP_MD_CTX *archive_md5_ctx; #elif defined(ARCHIVE_CRYPTO_MD5_WIN) typedef Digest_CTX archive_md5_ctx; #else @@ -175,7 +175,7 @@ typedef RIPEMD160_CTX archive_rmd160_ctx; #elif defined(ARCHIVE_CRYPTO_RMD160_NETTLE) typedef struct ripemd160_ctx archive_rmd160_ctx; #elif defined(ARCHIVE_CRYPTO_RMD160_OPENSSL) -typedef EVP_MD_CTX archive_rmd160_ctx; +typedef EVP_MD_CTX *archive_rmd160_ctx; #else typedef unsigned char archive_rmd160_ctx; #endif @@ -189,7 +189,7 @@ typedef CC_SHA1_CTX archive_sha1_ctx; #elif defined(ARCHIVE_CRYPTO_SHA1_NETTLE) typedef struct sha1_ctx archive_sha1_ctx; #elif defined(ARCHIVE_CRYPTO_SHA1_OPENSSL) -typedef EVP_MD_CTX archive_sha1_ctx; +typedef EVP_MD_CTX *archive_sha1_ctx; #elif defined(ARCHIVE_CRYPTO_SHA1_WIN) typedef Digest_CTX archive_sha1_ctx; #else @@ -209,7 +209,7 @@ typedef CC_SHA256_CTX archive_sha256_ctx; #elif defined(ARCHIVE_CRYPTO_SHA256_NETTLE) typedef struct sha256_ctx archive_sha256_ctx; #elif defined(ARCHIVE_CRYPTO_SHA256_OPENSSL) -typedef EVP_MD_CTX archive_sha256_ctx; +typedef EVP_MD_CTX *archive_sha256_ctx; #elif defined(ARCHIVE_CRYPTO_SHA256_WIN) typedef Digest_CTX archive_sha256_ctx; #else @@ -227,7 +227,7 @@ typedef CC_SHA512_CTX archive_sha384_ctx; #elif defined(ARCHIVE_CRYPTO_SHA384_NETTLE) typedef struct sha384_ctx archive_sha384_ctx; #elif defined(ARCHIVE_CRYPTO_SHA384_OPENSSL) -typedef EVP_MD_CTX archive_sha384_ctx; +typedef EVP_MD_CTX *archive_sha384_ctx; #elif defined(ARCHIVE_CRYPTO_SHA384_WIN) typedef Digest_CTX archive_sha384_ctx; #else @@ -247,7 +247,7 @@ typedef CC_SHA512_CTX archive_sha512_ctx; #elif defined(ARCHIVE_CRYPTO_SHA512_NETTLE) typedef struct sha512_ctx archive_sha512_ctx; #elif defined(ARCHIVE_CRYPTO_SHA512_OPENSSL) -typedef EVP_MD_CTX archive_sha512_ctx; +typedef EVP_MD_CTX *archive_sha512_ctx; #elif defined(ARCHIVE_CRYPTO_SHA512_WIN) typedef Digest_CTX archive_sha512_ctx; #else diff --git a/Utilities/cmlibarchive/libarchive/archive_hmac.c b/Utilities/cmlibarchive/libarchive/archive_hmac.c index 7857c0f..1e0ae28 100644 --- a/Utilities/cmlibarchive/libarchive/archive_hmac.c +++ b/Utilities/cmlibarchive/libarchive/archive_hmac.c @@ -176,8 +176,10 @@ __hmac_sha1_cleanup(archive_hmac_sha1_ctx *ctx) static int __hmac_sha1_init(archive_hmac_sha1_ctx *ctx, const uint8_t *key, size_t key_len) { - HMAC_CTX_init(ctx); - HMAC_Init(ctx, key, key_len, EVP_sha1()); + *ctx = HMAC_CTX_new(); + if (*ctx == NULL) + return -1; + HMAC_Init_ex(*ctx, key, key_len, EVP_sha1(), NULL); return 0; } @@ -185,22 +187,22 @@ static void __hmac_sha1_update(archive_hmac_sha1_ctx *ctx, const uint8_t *data, size_t data_len) { - HMAC_Update(ctx, data, data_len); + HMAC_Update(*ctx, data, data_len); } static void __hmac_sha1_final(archive_hmac_sha1_ctx *ctx, uint8_t *out, size_t *out_len) { unsigned int len = (unsigned int)*out_len; - HMAC_Final(ctx, out, &len); + HMAC_Final(*ctx, out, &len); *out_len = len; } static void __hmac_sha1_cleanup(archive_hmac_sha1_ctx *ctx) { - HMAC_CTX_cleanup(ctx); - memset(ctx, 0, sizeof(*ctx)); + HMAC_CTX_free(*ctx); + *ctx = NULL; } #else diff --git a/Utilities/cmlibarchive/libarchive/archive_hmac_private.h b/Utilities/cmlibarchive/libarchive/archive_hmac_private.h index 64de743..eb45c4e 100644 --- a/Utilities/cmlibarchive/libarchive/archive_hmac_private.h +++ b/Utilities/cmlibarchive/libarchive/archive_hmac_private.h @@ -70,9 +70,9 @@ typedef struct { typedef struct hmac_sha1_ctx archive_hmac_sha1_ctx; #elif defined(HAVE_LIBCRYPTO) -#include <openssl/hmac.h> +#include "archive_openssl_hmac_private.h" -typedef HMAC_CTX archive_hmac_sha1_ctx; +typedef HMAC_CTX* archive_hmac_sha1_ctx; #else diff --git a/Utilities/cmlibarchive/libarchive/archive_openssl_evp_private.h b/Utilities/cmlibarchive/libarchive/archive_openssl_evp_private.h new file mode 100644 index 0000000..0e97e27 --- /dev/null +++ b/Utilities/cmlibarchive/libarchive/archive_openssl_evp_private.h @@ -0,0 +1,51 @@ +/*- + * Copyright (c) 2003-2007 Tim Kientzle + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef ARCHIVE_OPENSSL_EVP_PRIVATE_H_INCLUDED +#define ARCHIVE_OPENSSL_EVP_PRIVATE_H_INCLUDED + +#include <openssl/evp.h> +#include <openssl/opensslv.h> + +#if OPENSSL_VERSION_NUMBER < 0x10100000L +#include <stdlib.h> /* malloc, free */ +#include <string.h> /* memset */ +static inline EVP_MD_CTX *EVP_MD_CTX_new(void) +{ + EVP_MD_CTX *ctx = (EVP_MD_CTX *)malloc(sizeof(EVP_MD_CTX)); + if (ctx != NULL) { + memset(ctx, 0, sizeof(*ctx)); + } + return ctx; +} + +static inline void EVP_MD_CTX_free(EVP_MD_CTX *ctx) +{ + EVP_MD_CTX_cleanup(ctx); + memset(ctx, 0, sizeof(*ctx)); + free(ctx); +} +#endif + +#endif diff --git a/Utilities/cmlibarchive/libarchive/archive_openssl_hmac_private.h b/Utilities/cmlibarchive/libarchive/archive_openssl_hmac_private.h new file mode 100644 index 0000000..d4ae0d1 --- /dev/null +++ b/Utilities/cmlibarchive/libarchive/archive_openssl_hmac_private.h @@ -0,0 +1,52 @@ +/*- + * Copyright (c) 2003-2007 Tim Kientzle + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef ARCHIVE_OPENSSL_HMAC_PRIVATE_H_INCLUDED +#define ARCHIVE_OPENSSL_HMAC_PRIVATE_H_INCLUDED + +#include <openssl/hmac.h> +#include <openssl/opensslv.h> + +#if OPENSSL_VERSION_NUMBER < 0x10100000L +#include <stdlib.h> /* malloc, free */ +#include <string.h> /* memset */ +static inline HMAC_CTX *HMAC_CTX_new(void) +{ + HMAC_CTX *ctx = (HMAC_CTX *)malloc(sizeof(HMAC_CTX)); + if (ctx != NULL) { + memset(ctx, 0, sizeof(*ctx)); + HMAC_CTX_init(ctx); + } + return ctx; +} + +static inline void HMAC_CTX_free(HMAC_CTX *ctx) +{ + HMAC_CTX_cleanup(ctx); + memset(ctx, 0, sizeof(*ctx)); + free(ctx); +} +#endif + +#endif diff --git a/Utilities/cmlibrhash/CMakeLists.txt b/Utilities/cmlibrhash/CMakeLists.txt index 340d946..aa28055 100644 --- a/Utilities/cmlibrhash/CMakeLists.txt +++ b/Utilities/cmlibrhash/CMakeLists.txt @@ -23,6 +23,8 @@ set(librhash_sources librhash/sha1.h librhash/sha256.c librhash/sha256.h + librhash/sha3.c + librhash/sha3.h librhash/sha512.c librhash/sha512.h librhash/ustd.h diff --git a/Utilities/cmlibrhash/librhash/algorithms.c b/Utilities/cmlibrhash/librhash/algorithms.c index 56d20b8..fc01690 100644 --- a/Utilities/cmlibrhash/librhash/algorithms.c +++ b/Utilities/cmlibrhash/librhash/algorithms.c @@ -39,8 +39,8 @@ #include "sha1.h" #include "sha256.h" #include "sha512.h" -#if 0 #include "sha3.h" +#if 0 #include "tiger.h" #include "tth.h" #include "whirlpool.h" @@ -104,11 +104,11 @@ rhash_info info_sha512 = { RHASH_SHA512, F_BE64, 64, "SHA-512", "sha512" }; #if 0 rhash_info info_edr256 = { RHASH_EDONR256, F_LE32, 32, "EDON-R256", "edon-r256" }; rhash_info info_edr512 = { RHASH_EDONR512, F_LE64, 64, "EDON-R512", "edon-r512" }; +#endif rhash_info info_sha3_224 = { RHASH_SHA3_224, F_LE64, 28, "SHA3-224", "sha3-224" }; rhash_info info_sha3_256 = { RHASH_SHA3_256, F_LE64, 32, "SHA3-256", "sha3-256" }; rhash_info info_sha3_384 = { RHASH_SHA3_384, F_LE64, 48, "SHA3-384", "sha3-384" }; rhash_info info_sha3_512 = { RHASH_SHA3_512, F_LE64, 64, "SHA3-512", "sha3-512" }; -#endif /* some helper macros */ #define dgshft(name) (((char*)&((name##_ctx*)0)->hash) - (char*)0) @@ -148,11 +148,11 @@ rhash_hash_info rhash_hash_info_default[RHASH_HASH_COUNT] = #if 0 { &info_edr256, sizeof(edonr_ctx), dgshft2(edonr, u.data256.hash) + 32, iuf(rhash_edonr256), 0 }, /* 256 bit */ { &info_edr512, sizeof(edonr_ctx), dgshft2(edonr, u.data512.hash) + 64, iuf(rhash_edonr512), 0 }, /* 512 bit */ +#endif { &info_sha3_224, sizeof(sha3_ctx), dgshft(sha3), ini(rhash_sha3_224), upd(rhash_sha3), fin(rhash_sha3), 0 }, /* 224 bit */ { &info_sha3_256, sizeof(sha3_ctx), dgshft(sha3), ini(rhash_sha3_256), upd(rhash_sha3), fin(rhash_sha3), 0 }, /* 256 bit */ { &info_sha3_384, sizeof(sha3_ctx), dgshft(sha3), ini(rhash_sha3_384), upd(rhash_sha3), fin(rhash_sha3), 0 }, /* 384 bit */ { &info_sha3_512, sizeof(sha3_ctx), dgshft(sha3), ini(rhash_sha3_512), upd(rhash_sha3), fin(rhash_sha3), 0 }, /* 512 bit */ -#endif }; /** diff --git a/Utilities/cmlibrhash/librhash/rhash.h b/Utilities/cmlibrhash/librhash/rhash.h index 6d18c18..cee0e25 100644 --- a/Utilities/cmlibrhash/librhash/rhash.h +++ b/Utilities/cmlibrhash/librhash/rhash.h @@ -66,14 +66,22 @@ enum rhash_ids RHASH_SHA256 = 0x08, RHASH_SHA384 = 0x10, RHASH_SHA512 = 0x20, + RHASH_SHA3_224 = 0x40, + RHASH_SHA3_256 = 0x80, + RHASH_SHA3_384 = 0x100, + RHASH_SHA3_512 = 0x200, RHASH_ALL_HASHES = RHASH_MD5 | RHASH_SHA1 | RHASH_SHA224 | RHASH_SHA256 | RHASH_SHA384 | - RHASH_SHA512, - RHASH_HASH_COUNT = 6 + RHASH_SHA512 | + RHASH_SHA3_224 | + RHASH_SHA3_256 | + RHASH_SHA3_384 | + RHASH_SHA3_512, + RHASH_HASH_COUNT = 10 #endif }; @@ -145,7 +153,7 @@ typedef struct rhash_info /* information functions */ RHASH_API int rhash_count(void); /* number of supported hashes */ RHASH_API int rhash_get_digest_size(unsigned hash_id); /* size of binary message digest */ -RHASH_API int rhash_get_hash_length(unsigned hash_id); /* length of formated hash string */ +RHASH_API int rhash_get_hash_length(unsigned hash_id); /* length of formatted hash string */ RHASH_API int rhash_is_base32(unsigned hash_id); /* default digest output format */ RHASH_API const char* rhash_get_name(unsigned hash_id); /* get hash function name */ RHASH_API const char* rhash_get_magnet_name(unsigned hash_id); /* get name part of magnet urn */ diff --git a/Utilities/cmlibrhash/librhash/sha256.c b/Utilities/cmlibrhash/librhash/sha256.c index 064dfe2..af5b0fe 100644 --- a/Utilities/cmlibrhash/librhash/sha256.c +++ b/Utilities/cmlibrhash/librhash/sha256.c @@ -218,8 +218,8 @@ void rhash_sha256_final(sha256_ctx *ctx, unsigned char* result) /* pad message and run for last block */ /* append the byte 0x80 to the message */ - ctx->message[index] &= le2me_32(~(0xFFFFFFFF << shift)); - ctx->message[index++] ^= le2me_32(0x80 << shift); + ctx->message[index] &= le2me_32(~(0xFFFFFFFFu << shift)); + ctx->message[index++] ^= le2me_32(0x80u << shift); /* if no room left in the message to store 64-bit message length */ if (index > 14) { diff --git a/Utilities/cmlibrhash/librhash/sha3.c b/Utilities/cmlibrhash/librhash/sha3.c new file mode 100644 index 0000000..e4a845f --- /dev/null +++ b/Utilities/cmlibrhash/librhash/sha3.c @@ -0,0 +1,356 @@ +/* sha3.c - an implementation of Secure Hash Algorithm 3 (Keccak). + * based on the + * The Keccak SHA-3 submission. Submission to NIST (Round 3), 2011 + * by Guido Bertoni, Joan Daemen, Michaƫl Peeters and Gilles Van Assche + * + * Copyright: 2013 Aleksey Kravchenko <rhash.admin@gmail.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. Use this program at your own risk! + */ + +#include <assert.h> +#include <string.h> +#include "byte_order.h" +#include "sha3.h" + +/* constants */ +#define NumberOfRounds 24 + +/* SHA3 (Keccak) constants for 24 rounds */ +static uint64_t keccak_round_constants[NumberOfRounds] = { + I64(0x0000000000000001), I64(0x0000000000008082), I64(0x800000000000808A), I64(0x8000000080008000), + I64(0x000000000000808B), I64(0x0000000080000001), I64(0x8000000080008081), I64(0x8000000000008009), + I64(0x000000000000008A), I64(0x0000000000000088), I64(0x0000000080008009), I64(0x000000008000000A), + I64(0x000000008000808B), I64(0x800000000000008B), I64(0x8000000000008089), I64(0x8000000000008003), + I64(0x8000000000008002), I64(0x8000000000000080), I64(0x000000000000800A), I64(0x800000008000000A), + I64(0x8000000080008081), I64(0x8000000000008080), I64(0x0000000080000001), I64(0x8000000080008008) +}; + +/* Initializing a sha3 context for given number of output bits */ +static void rhash_keccak_init(sha3_ctx *ctx, unsigned bits) +{ + /* NB: The Keccak capacity parameter = bits * 2 */ + unsigned rate = 1600 - bits * 2; + + memset(ctx, 0, sizeof(sha3_ctx)); + ctx->block_size = rate / 8; + assert(rate <= 1600 && (rate % 64) == 0); +} + +/** + * Initialize context before calculating hash. + * + * @param ctx context to initialize + */ +void rhash_sha3_224_init(sha3_ctx *ctx) +{ + rhash_keccak_init(ctx, 224); +} + +/** + * Initialize context before calculating hash. + * + * @param ctx context to initialize + */ +void rhash_sha3_256_init(sha3_ctx *ctx) +{ + rhash_keccak_init(ctx, 256); +} + +/** + * Initialize context before calculating hash. + * + * @param ctx context to initialize + */ +void rhash_sha3_384_init(sha3_ctx *ctx) +{ + rhash_keccak_init(ctx, 384); +} + +/** + * Initialize context before calculating hash. + * + * @param ctx context to initialize + */ +void rhash_sha3_512_init(sha3_ctx *ctx) +{ + rhash_keccak_init(ctx, 512); +} + +/* Keccak theta() transformation */ +static void keccak_theta(uint64_t *A) +{ + unsigned int x; + uint64_t C[5], D[5]; + + for (x = 0; x < 5; x++) { + C[x] = A[x] ^ A[x + 5] ^ A[x + 10] ^ A[x + 15] ^ A[x + 20]; + } + D[0] = ROTL64(C[1], 1) ^ C[4]; + D[1] = ROTL64(C[2], 1) ^ C[0]; + D[2] = ROTL64(C[3], 1) ^ C[1]; + D[3] = ROTL64(C[4], 1) ^ C[2]; + D[4] = ROTL64(C[0], 1) ^ C[3]; + + for (x = 0; x < 5; x++) { + A[x] ^= D[x]; + A[x + 5] ^= D[x]; + A[x + 10] ^= D[x]; + A[x + 15] ^= D[x]; + A[x + 20] ^= D[x]; + } +} + +/* Keccak pi() transformation */ +static void keccak_pi(uint64_t *A) +{ + uint64_t A1; + A1 = A[1]; + A[ 1] = A[ 6]; + A[ 6] = A[ 9]; + A[ 9] = A[22]; + A[22] = A[14]; + A[14] = A[20]; + A[20] = A[ 2]; + A[ 2] = A[12]; + A[12] = A[13]; + A[13] = A[19]; + A[19] = A[23]; + A[23] = A[15]; + A[15] = A[ 4]; + A[ 4] = A[24]; + A[24] = A[21]; + A[21] = A[ 8]; + A[ 8] = A[16]; + A[16] = A[ 5]; + A[ 5] = A[ 3]; + A[ 3] = A[18]; + A[18] = A[17]; + A[17] = A[11]; + A[11] = A[ 7]; + A[ 7] = A[10]; + A[10] = A1; + /* note: A[ 0] is left as is */ +} + +/* Keccak chi() transformation */ +static void keccak_chi(uint64_t *A) +{ + int i; + for (i = 0; i < 25; i += 5) { + uint64_t A0 = A[0 + i], A1 = A[1 + i]; + A[0 + i] ^= ~A1 & A[2 + i]; + A[1 + i] ^= ~A[2 + i] & A[3 + i]; + A[2 + i] ^= ~A[3 + i] & A[4 + i]; + A[3 + i] ^= ~A[4 + i] & A0; + A[4 + i] ^= ~A0 & A1; + } +} + +static void rhash_sha3_permutation(uint64_t *state) +{ + int round; + for (round = 0; round < NumberOfRounds; round++) + { + keccak_theta(state); + + /* apply Keccak rho() transformation */ + state[ 1] = ROTL64(state[ 1], 1); + state[ 2] = ROTL64(state[ 2], 62); + state[ 3] = ROTL64(state[ 3], 28); + state[ 4] = ROTL64(state[ 4], 27); + state[ 5] = ROTL64(state[ 5], 36); + state[ 6] = ROTL64(state[ 6], 44); + state[ 7] = ROTL64(state[ 7], 6); + state[ 8] = ROTL64(state[ 8], 55); + state[ 9] = ROTL64(state[ 9], 20); + state[10] = ROTL64(state[10], 3); + state[11] = ROTL64(state[11], 10); + state[12] = ROTL64(state[12], 43); + state[13] = ROTL64(state[13], 25); + state[14] = ROTL64(state[14], 39); + state[15] = ROTL64(state[15], 41); + state[16] = ROTL64(state[16], 45); + state[17] = ROTL64(state[17], 15); + state[18] = ROTL64(state[18], 21); + state[19] = ROTL64(state[19], 8); + state[20] = ROTL64(state[20], 18); + state[21] = ROTL64(state[21], 2); + state[22] = ROTL64(state[22], 61); + state[23] = ROTL64(state[23], 56); + state[24] = ROTL64(state[24], 14); + + keccak_pi(state); + keccak_chi(state); + + /* apply iota(state, round) */ + *state ^= keccak_round_constants[round]; + } +} + +/** + * The core transformation. Process the specified block of data. + * + * @param hash the algorithm state + * @param block the message block to process + * @param block_size the size of the processed block in bytes + */ +static void rhash_sha3_process_block(uint64_t hash[25], const uint64_t *block, size_t block_size) +{ + /* expanded loop */ + hash[ 0] ^= le2me_64(block[ 0]); + hash[ 1] ^= le2me_64(block[ 1]); + hash[ 2] ^= le2me_64(block[ 2]); + hash[ 3] ^= le2me_64(block[ 3]); + hash[ 4] ^= le2me_64(block[ 4]); + hash[ 5] ^= le2me_64(block[ 5]); + hash[ 6] ^= le2me_64(block[ 6]); + hash[ 7] ^= le2me_64(block[ 7]); + hash[ 8] ^= le2me_64(block[ 8]); + /* if not sha3-512 */ + if (block_size > 72) { + hash[ 9] ^= le2me_64(block[ 9]); + hash[10] ^= le2me_64(block[10]); + hash[11] ^= le2me_64(block[11]); + hash[12] ^= le2me_64(block[12]); + /* if not sha3-384 */ + if (block_size > 104) { + hash[13] ^= le2me_64(block[13]); + hash[14] ^= le2me_64(block[14]); + hash[15] ^= le2me_64(block[15]); + hash[16] ^= le2me_64(block[16]); + /* if not sha3-256 */ + if (block_size > 136) { + hash[17] ^= le2me_64(block[17]); +#ifdef FULL_SHA3_FAMILY_SUPPORT + /* if not sha3-224 */ + if (block_size > 144) { + hash[18] ^= le2me_64(block[18]); + hash[19] ^= le2me_64(block[19]); + hash[20] ^= le2me_64(block[20]); + hash[21] ^= le2me_64(block[21]); + hash[22] ^= le2me_64(block[22]); + hash[23] ^= le2me_64(block[23]); + hash[24] ^= le2me_64(block[24]); + } +#endif + } + } + } + /* make a permutation of the hash */ + rhash_sha3_permutation(hash); +} + +#define SHA3_FINALIZED 0x80000000 + +/** + * Calculate message hash. + * Can be called repeatedly with chunks of the message to be hashed. + * + * @param ctx the algorithm context containing current hashing state + * @param msg message chunk + * @param size length of the message chunk + */ +void rhash_sha3_update(sha3_ctx *ctx, const unsigned char *msg, size_t size) +{ + size_t index = (size_t)ctx->rest; + size_t block_size = (size_t)ctx->block_size; + + if (ctx->rest & SHA3_FINALIZED) return; /* too late for additional input */ + ctx->rest = (unsigned)((ctx->rest + size) % block_size); + + /* fill partial block */ + if (index) { + size_t left = block_size - index; + memcpy((char*)ctx->message + index, msg, (size < left ? size : left)); + if (size < left) return; + + /* process partial block */ + rhash_sha3_process_block(ctx->hash, ctx->message, block_size); + msg += left; + size -= left; + } + while (size >= block_size) { + uint64_t* aligned_message_block; + if (IS_ALIGNED_64(msg)) { + /* the most common case is processing of an already aligned message + without copying it */ + aligned_message_block = (uint64_t*)msg; + } else { + memcpy(ctx->message, msg, block_size); + aligned_message_block = ctx->message; + } + + rhash_sha3_process_block(ctx->hash, aligned_message_block, block_size); + msg += block_size; + size -= block_size; + } + if (size) { + memcpy(ctx->message, msg, size); /* save leftovers */ + } +} + +/** + * Store calculated hash into the given array. + * + * @param ctx the algorithm context containing current hashing state + * @param result calculated hash in binary form + */ +void rhash_sha3_final(sha3_ctx *ctx, unsigned char* result) +{ + size_t digest_length = 100 - ctx->block_size / 2; + const size_t block_size = ctx->block_size; + + if (!(ctx->rest & SHA3_FINALIZED)) + { + /* clear the rest of the data queue */ + memset((char*)ctx->message + ctx->rest, 0, block_size - ctx->rest); + ((char*)ctx->message)[ctx->rest] |= 0x06; + ((char*)ctx->message)[block_size - 1] |= 0x80; + + /* process final block */ + rhash_sha3_process_block(ctx->hash, ctx->message, block_size); + ctx->rest = SHA3_FINALIZED; /* mark context as finalized */ + } + + assert(block_size > digest_length); + if (result) me64_to_le_str(result, ctx->hash, digest_length); +} + +#ifdef USE_KECCAK +/** +* Store calculated hash into the given array. +* +* @param ctx the algorithm context containing current hashing state +* @param result calculated hash in binary form +*/ +void rhash_keccak_final(sha3_ctx *ctx, unsigned char* result) +{ + size_t digest_length = 100 - ctx->block_size / 2; + const size_t block_size = ctx->block_size; + + if (!(ctx->rest & SHA3_FINALIZED)) + { + /* clear the rest of the data queue */ + memset((char*)ctx->message + ctx->rest, 0, block_size - ctx->rest); + ((char*)ctx->message)[ctx->rest] |= 0x01; + ((char*)ctx->message)[block_size - 1] |= 0x80; + + /* process final block */ + rhash_sha3_process_block(ctx->hash, ctx->message, block_size); + ctx->rest = SHA3_FINALIZED; /* mark context as finalized */ + } + + assert(block_size > digest_length); + if (result) me64_to_le_str(result, ctx->hash, digest_length); +} +#endif /* USE_KECCAK */ diff --git a/Utilities/cmlibrhash/librhash/sha3.h b/Utilities/cmlibrhash/librhash/sha3.h new file mode 100644 index 0000000..2831997 --- /dev/null +++ b/Utilities/cmlibrhash/librhash/sha3.h @@ -0,0 +1,54 @@ +/* sha3.h */ +#ifndef RHASH_SHA3_H +#define RHASH_SHA3_H +#include "ustd.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define sha3_224_hash_size 28 +#define sha3_256_hash_size 32 +#define sha3_384_hash_size 48 +#define sha3_512_hash_size 64 +#define sha3_max_permutation_size 25 +#define sha3_max_rate_in_qwords 24 + +/** + * SHA3 Algorithm context. + */ +typedef struct sha3_ctx +{ + /* 1600 bits algorithm hashing state */ + uint64_t hash[sha3_max_permutation_size]; + /* 1536-bit buffer for leftovers */ + uint64_t message[sha3_max_rate_in_qwords]; + /* count of bytes in the message[] buffer */ + unsigned rest; + /* size of a message block processed at once */ + unsigned block_size; +} sha3_ctx; + +/* methods for calculating the hash function */ + +void rhash_sha3_224_init(sha3_ctx *ctx); +void rhash_sha3_256_init(sha3_ctx *ctx); +void rhash_sha3_384_init(sha3_ctx *ctx); +void rhash_sha3_512_init(sha3_ctx *ctx); +void rhash_sha3_update(sha3_ctx *ctx, const unsigned char* msg, size_t size); +void rhash_sha3_final(sha3_ctx *ctx, unsigned char* result); + +#ifdef USE_KECCAK +#define rhash_keccak_224_init rhash_sha3_224_init +#define rhash_keccak_256_init rhash_sha3_256_init +#define rhash_keccak_384_init rhash_sha3_384_init +#define rhash_keccak_512_init rhash_sha3_512_init +#define rhash_keccak_update rhash_sha3_update +void rhash_keccak_final(sha3_ctx *ctx, unsigned char* result); +#endif + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ + +#endif /* RHASH_SHA3_H */ @@ -372,6 +372,7 @@ CMAKE_CXX_SOURCES="\ cmParseArgumentsCommand \ cmPathLabel \ cmPolicies \ + cmProcessOutput \ cmProjectCommand \ cmProperty \ cmPropertyDefinition \ @@ -1423,6 +1424,7 @@ fi cmake_c_flags_String="-DKWSYS_STRING_C" if ${cmake_system_mingw}; then cmake_c_flags_EncodingC="-DKWSYS_ENCODING_DEFAULT_CODEPAGE=CP_ACP" + cmake_cxx_flags_cmProcessOutput="${cmake_c_flags_EncodingC}" fi cmake_cxx_flags_SystemTools=" -DKWSYS_CXX_HAS_SETENV=${KWSYS_CXX_HAS_SETENV} @@ -1439,8 +1441,9 @@ echo "cmake: ${objs}" > "${cmake_bootstrap_dir}/Makefile" echo " ${cmake_cxx_compiler} ${cmake_ld_flags} ${cmake_cxx_flags} ${objs} -o cmake" >> "${cmake_bootstrap_dir}/Makefile" for a in ${CMAKE_CXX_SOURCES}; do src=`cmake_escape "${cmake_source_dir}/Source/${a}.cxx"` + src_flags=`eval echo \\${cmake_cxx_flags_\${a}}` echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile" - echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile" + echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} ${src_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile" done echo "cmBootstrapCommands1.o : $cmBootstrapCommands1Deps" >> "${cmake_bootstrap_dir}/Makefile" echo "cmBootstrapCommands2.o : $cmBootstrapCommands2Deps" >> "${cmake_bootstrap_dir}/Makefile" |