diff options
54 files changed, 493 insertions, 278 deletions
diff --git a/Help/command/find_package.rst b/Help/command/find_package.rst index 64a16f3..6753268 100644 --- a/Help/command/find_package.rst +++ b/Help/command/find_package.rst @@ -302,23 +302,23 @@ enabled. are intended to be used on the command line with a ``-DVAR=value``. The values are interpreted as :ref:`semicolon-separated lists <CMake Language Lists>`. This can be skipped if ``NO_CMAKE_PATH`` is passed or by setting the - :variable:`CMAKE_FIND_USE_CMAKE_PATH` to ``FALSE``:: + :variable:`CMAKE_FIND_USE_CMAKE_PATH` to ``FALSE``: - CMAKE_PREFIX_PATH - CMAKE_FRAMEWORK_PATH - CMAKE_APPBUNDLE_PATH + * :variable:`CMAKE_PREFIX_PATH` + * :variable:`CMAKE_FRAMEWORK_PATH` + * :variable:`CMAKE_APPBUNDLE_PATH` 3. Search paths specified in cmake-specific environment variables. These are intended to be set in the user's shell configuration, and therefore use the host's native path separator (``;`` on Windows and ``:`` on UNIX). This can be skipped if ``NO_CMAKE_ENVIRONMENT_PATH`` is passed or by setting - the :variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH` to ``FALSE``:: + the :variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH` to ``FALSE``: - <PackageName>_DIR - CMAKE_PREFIX_PATH - CMAKE_FRAMEWORK_PATH - CMAKE_APPBUNDLE_PATH + * ``<PackageName>_DIR`` + * :envvar:`CMAKE_PREFIX_PATH` + * ``CMAKE_FRAMEWORK_PATH`` + * ``CMAKE_APPBUNDLE_PATH`` 4. Search paths specified by the ``HINTS`` option. These should be paths computed by system introspection, such as a hint provided by the diff --git a/Help/cpack_gen/nsis.rst b/Help/cpack_gen/nsis.rst index d1e495f..0dd876e 100644 --- a/Help/cpack_gen/nsis.rst +++ b/Help/cpack_gen/nsis.rst @@ -155,3 +155,7 @@ on Windows Nullsoft Scriptable Install System. .. variable:: CPACK_NSIS_MUI_HEADERIMAGE The image to display on the header of installers pages. + +.. variable:: CPACK_NSIS_MANIFEST_DPI_AWARE + + If set, declares that the installer is DPI-aware. diff --git a/Help/envvar/CMAKE_PREFIX_PATH.rst b/Help/envvar/CMAKE_PREFIX_PATH.rst new file mode 100644 index 0000000..276fdd6 --- /dev/null +++ b/Help/envvar/CMAKE_PREFIX_PATH.rst @@ -0,0 +1,17 @@ +CMAKE_PREFIX_PATH +----------------- + +.. include:: ENV_VAR.txt + +The ``CMAKE_PREFIX_PATH`` environment variable may be set to a list of +directories specifying installation *prefixes* to be searched by the +:command:`find_package`, :command:`find_program`, :command:`find_library`, +:command:`find_file`, and :command:`find_path` commands. Each command will +add appropriate subdirectories (like ``bin``, ``lib``, or ``include``) +as specified in its own documentation. + +This variable may hold a single prefix or a list of prefixes separated +by ``:`` on UNIX or ``;`` on Windows (the same as the ``PATH`` environment +variable convention on those platforms). + +See also the :variable:`CMAKE_PREFIX_PATH` CMake variable. diff --git a/Help/manual/cmake-env-variables.7.rst b/Help/manual/cmake-env-variables.7.rst index adfc39e..dfdf415 100644 --- a/Help/manual/cmake-env-variables.7.rst +++ b/Help/manual/cmake-env-variables.7.rst @@ -14,6 +14,13 @@ For general information on environment variables, see the :ref:`Environment Variables <CMake Language Environment Variables>` section in the cmake-language manual. +Environment Variables that Change Behavior +========================================== + +.. toctree:: + :maxdepth: 1 + + /envvar/CMAKE_PREFIX_PATH Environment Variables that Control the Build ============================================ diff --git a/Help/release/dev/nsis-dpi-aware.rst b/Help/release/dev/nsis-dpi-aware.rst new file mode 100644 index 0000000..8b5032e --- /dev/null +++ b/Help/release/dev/nsis-dpi-aware.rst @@ -0,0 +1,6 @@ +nsis-dpi-aware +-------------- + +* The :cpack_gen:`CPack NSIS Generator` gained a new variable + :variable:`CPACK_NSIS_MANIFEST_DPI_AWARE` to declare that the + installer is DPI-aware. diff --git a/Modules/CMakeASMCompiler.cmake.in b/Modules/CMakeASMCompiler.cmake.in index 858c053..3953b30 100644 --- a/Modules/CMakeASMCompiler.cmake.in +++ b/Modules/CMakeASMCompiler.cmake.in @@ -12,6 +12,7 @@ set(CMAKE_ASM@ASM_DIALECT@_COMPILER_VERSION "@_CMAKE_ASM_COMPILER_VERSION@") set(CMAKE_ASM@ASM_DIALECT@_COMPILER_ENV_VAR "@_CMAKE_ASM_COMPILER_ENV_VAR@") @_SET_CMAKE_ASM_COMPILER_ID_VENDOR_MATCH@ @_SET_CMAKE_ASM_COMPILER_ARCHITECTURE_ID@ +@_SET_CMAKE_ASM_COMPILER_SYSROOT@ set(CMAKE_ASM@ASM_DIALECT@_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC) set(CMAKE_ASM@ASM_DIALECT@_LINKER_PREFERENCE 0) diff --git a/Modules/CMakeCCompiler.cmake.in b/Modules/CMakeCCompiler.cmake.in index 9b8d423..eea3f5d 100644 --- a/Modules/CMakeCCompiler.cmake.in +++ b/Modules/CMakeCCompiler.cmake.in @@ -15,6 +15,7 @@ set(CMAKE_C_SIMULATE_ID "@CMAKE_C_SIMULATE_ID@") set(CMAKE_C_COMPILER_FRONTEND_VARIANT "@CMAKE_C_COMPILER_FRONTEND_VARIANT@") set(CMAKE_C_SIMULATE_VERSION "@CMAKE_C_SIMULATE_VERSION@") @_SET_CMAKE_C_COMPILER_ARCHITECTURE_ID@ +@_SET_CMAKE_C_COMPILER_SYSROOT@ @SET_MSVC_C_ARCHITECTURE_ID@ @SET_CMAKE_XCODE_ARCHS@ set(CMAKE_AR "@CMAKE_AR@") diff --git a/Modules/CMakeCUDACompiler.cmake.in b/Modules/CMakeCUDACompiler.cmake.in index 14a39a9..289e96e 100644 --- a/Modules/CMakeCUDACompiler.cmake.in +++ b/Modules/CMakeCUDACompiler.cmake.in @@ -16,6 +16,7 @@ set(CMAKE_CUDA_SIMULATE_ID "@CMAKE_CUDA_SIMULATE_ID@") set(CMAKE_CUDA_COMPILER_FRONTEND_VARIANT "@CMAKE_CUDA_COMPILER_FRONTEND_VARIANT@") set(CMAKE_CUDA_SIMULATE_VERSION "@CMAKE_CUDA_SIMULATE_VERSION@") @SET_MSVC_CUDA_ARCHITECTURE_ID@ +@_SET_CMAKE_CUDA_COMPILER_SYSROOT@ set(CMAKE_CUDA_COMPILER_ENV_VAR "CUDACXX") set(CMAKE_CUDA_HOST_COMPILER_ENV_VAR "CUDAHOSTCXX") diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in index efb8abf..09bdc23 100644 --- a/Modules/CMakeCXXCompiler.cmake.in +++ b/Modules/CMakeCXXCompiler.cmake.in @@ -17,6 +17,7 @@ set(CMAKE_CXX_SIMULATE_ID "@CMAKE_CXX_SIMULATE_ID@") set(CMAKE_CXX_COMPILER_FRONTEND_VARIANT "@CMAKE_CXX_COMPILER_FRONTEND_VARIANT@") set(CMAKE_CXX_SIMULATE_VERSION "@CMAKE_CXX_SIMULATE_VERSION@") @_SET_CMAKE_CXX_COMPILER_ARCHITECTURE_ID@ +@_SET_CMAKE_CXX_COMPILER_SYSROOT@ @SET_MSVC_CXX_ARCHITECTURE_ID@ @SET_CMAKE_XCODE_ARCHS@ set(CMAKE_AR "@CMAKE_AR@") diff --git a/Modules/CMakeDetermineASMCompiler.cmake b/Modules/CMakeDetermineASMCompiler.cmake index 86fb057..bc8b86b 100644 --- a/Modules/CMakeDetermineASMCompiler.cmake +++ b/Modules/CMakeDetermineASMCompiler.cmake @@ -134,6 +134,9 @@ if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) list(GET _all_compileid_matches "-1" CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID) endif() endif() + + _cmake_find_compiler_sysroot(ASM${ASM_DIALECT}) + unset(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_OUTPUT) unset(_all_compileid_matches) unset(_compileid) @@ -211,6 +214,14 @@ foreach(_var set(_CMAKE_ASM_${_var} "${CMAKE_ASM${ASM_DIALECT}_${_var}}") endforeach() +if(CMAKE_ASM${ASM_DIALECT}_COMPILER_SYSROOT) + string(CONCAT _SET_CMAKE_ASM_COMPILER_SYSROOT + "set(CMAKE_ASM${ASM_DIALECT}_COMPILER_SYSROOT \"${CMAKE_ASM${ASM_DIALECT}_COMPILER_SYSROOT}\")\n" + "set(CMAKE_COMPILER_SYSROOT \"${CMAKE_ASM${ASM_DIALECT}_COMPILER_SYSROOT}\")") +else() + set(_SET_CMAKE_ASM_COMPILER_SYSROOT "") +endif() + if(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_MATCH) set(_SET_CMAKE_ASM_COMPILER_ID_VENDOR_MATCH "set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_MATCH [==[${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_MATCH}]==])") diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index 9d395e5..f870956 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -115,6 +115,8 @@ if(NOT CMAKE_C_COMPILER_ID_RUN) include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake) CMAKE_DETERMINE_COMPILER_ID(C CFLAGS CMakeCCompilerId.c) + _cmake_find_compiler_sysroot(C) + # Set old compiler and platform id variables. if(CMAKE_C_COMPILER_ID STREQUAL "GNU") set(CMAKE_COMPILER_IS_GNUCC 1) @@ -191,6 +193,14 @@ include(CMakeFindBinUtils) include(Compiler/${CMAKE_C_COMPILER_ID}-FindBinUtils OPTIONAL) unset(_CMAKE_PROCESSING_LANGUAGE) +if(CMAKE_C_COMPILER_SYSROOT) + string(CONCAT _SET_CMAKE_C_COMPILER_SYSROOT + "set(CMAKE_C_COMPILER_SYSROOT \"${CMAKE_C_COMPILER_SYSROOT}\")\n" + "set(CMAKE_COMPILER_SYSROOT \"${CMAKE_C_COMPILER_SYSROOT}\")") +else() + set(_SET_CMAKE_C_COMPILER_SYSROOT "") +endif() + if(CMAKE_C_COMPILER_ARCHITECTURE_ID) set(_SET_CMAKE_C_COMPILER_ARCHITECTURE_ID "set(CMAKE_C_COMPILER_ARCHITECTURE_ID ${CMAKE_C_COMPILER_ARCHITECTURE_ID})") diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake index 95c3cc9..55ca800 100644 --- a/Modules/CMakeDetermineCUDACompiler.cmake +++ b/Modules/CMakeDetermineCUDACompiler.cmake @@ -70,6 +70,8 @@ if(NOT CMAKE_CUDA_COMPILER_ID_RUN) include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake) CMAKE_DETERMINE_COMPILER_ID(CUDA CUDAFLAGS CMakeCUDACompilerId.cu) + + _cmake_find_compiler_sysroot(CUDA) endif() set(_CMAKE_PROCESSING_LANGUAGE "CUDA") @@ -189,6 +191,14 @@ elseif(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA") endif() endif() +if(CMAKE_CUDA_COMPILER_SYSROOT) + string(CONCAT _SET_CMAKE_CUDA_COMPILER_SYSROOT + "set(CMAKE_CUDA_COMPILER_SYSROOT \"${CMAKE_CUDA_COMPILER_SYSROOT}\")\n" + "set(CMAKE_COMPILER_SYSROOT \"${CMAKE_CUDA_COMPILER_SYSROOT}\")") +else() + set(_SET_CMAKE_CUDA_COMPILER_SYSROOT "") +endif() + # Determine CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA") set(CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES) diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index ebac435..e6b46b8 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -110,6 +110,8 @@ if(NOT CMAKE_CXX_COMPILER_ID_RUN) include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake) CMAKE_DETERMINE_COMPILER_ID(CXX CXXFLAGS CMakeCXXCompilerId.cpp) + _cmake_find_compiler_sysroot(CXX) + # Set old compiler and platform id variables. if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set(CMAKE_COMPILER_IS_GNUCXX 1) @@ -189,6 +191,14 @@ include(CMakeFindBinUtils) include(Compiler/${CMAKE_CXX_COMPILER_ID}-FindBinUtils OPTIONAL) unset(_CMAKE_PROCESSING_LANGUAGE) +if(CMAKE_CXX_COMPILER_SYSROOT) + string(CONCAT _SET_CMAKE_CXX_COMPILER_SYSROOT + "set(CMAKE_CXX_COMPILER_SYSROOT \"${CMAKE_CXX_COMPILER_SYSROOT}\")\n" + "set(CMAKE_COMPILER_SYSROOT \"${CMAKE_CXX_COMPILER_SYSROOT}\")") +else() + set(_SET_CMAKE_CXX_COMPILER_SYSROOT "") +endif() + if(CMAKE_CXX_COMPILER_ARCHITECTURE_ID) set(_SET_CMAKE_CXX_COMPILER_ARCHITECTURE_ID "set(CMAKE_CXX_COMPILER_ARCHITECTURE_ID ${CMAKE_CXX_COMPILER_ARCHITECTURE_ID})") diff --git a/Modules/CMakeDetermineCompiler.cmake b/Modules/CMakeDetermineCompiler.cmake index c37adae..7afae8a 100644 --- a/Modules/CMakeDetermineCompiler.cmake +++ b/Modules/CMakeDetermineCompiler.cmake @@ -118,3 +118,18 @@ macro(_cmake_find_compiler_path lang) endif() endif() endmacro() + +function(_cmake_find_compiler_sysroot lang) + if(CMAKE_${lang}_COMPILER_ID STREQUAL "GNU") + execute_process(COMMAND "${CMAKE_${lang}_COMPILER}" -print-sysroot + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE _cmake_sysroot_run_out + ERROR_VARIABLE _cmake_sysroot_run_err) + + if(_cmake_sysroot_run_out AND NOT _cmake_sysroot_run_err AND IS_DIRECTORY "${_cmake_sysroot_run_out}/usr") + set(CMAKE_${lang}_COMPILER_SYSROOT "${_cmake_sysroot_run_out}/usr" PARENT_SCOPE) + else() + set(CMAKE_${lang}_COMPILER_SYSROOT "" PARENT_SCOPE) + endif() + endif() +endfunction() diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake index 6731abe..5f5a70a 100644 --- a/Modules/CMakeDetermineFortranCompiler.cmake +++ b/Modules/CMakeDetermineFortranCompiler.cmake @@ -186,6 +186,8 @@ if(NOT CMAKE_Fortran_COMPILER_ID_RUN) include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake) CMAKE_DETERMINE_COMPILER_ID(Fortran FFLAGS CMakeFortranCompilerId.F) + _cmake_find_compiler_sysroot(Fortran) + # Fall back to old is-GNU test. if(NOT CMAKE_Fortran_COMPILER_ID) execute_process(COMMAND ${CMAKE_Fortran_COMPILER} ${CMAKE_Fortran_COMPILER_ID_FLAGS_LIST} -E "${CMAKE_ROOT}/Modules/CMakeTestGNU.c" @@ -276,6 +278,14 @@ if(CMAKE_Fortran_XL_CPP) "set(CMAKE_Fortran_XL_CPP \"${CMAKE_Fortran_XL_CPP}\")") endif() +if(CMAKE_Fortran_COMPILER_SYSROOT) + string(CONCAT _SET_CMAKE_Fortran_COMPILER_SYSROOT + "set(CMAKE_Fortran_COMPILER_SYSROOT \"${CMAKE_Fortran_COMPILER_SYSROOT}\")\n" + "set(CMAKE_COMPILER_SYSROOT \"${CMAKE_Fortran_COMPILER_SYSROOT}\")") +else() + set(_SET_CMAKE_Fortran_COMPILER_SYSROOT "") +endif() + if(CMAKE_Fortran_COMPILER_ARCHITECTURE_ID) set(_SET_CMAKE_Fortran_COMPILER_ARCHITECTURE_ID "set(CMAKE_Fortran_COMPILER_ARCHITECTURE_ID ${CMAKE_Fortran_COMPILER_ARCHITECTURE_ID})") diff --git a/Modules/CMakeFortranCompiler.cmake.in b/Modules/CMakeFortranCompiler.cmake.in index 34f44aa..06ee528 100644 --- a/Modules/CMakeFortranCompiler.cmake.in +++ b/Modules/CMakeFortranCompiler.cmake.in @@ -8,6 +8,7 @@ set(CMAKE_Fortran_SIMULATE_ID "@CMAKE_Fortran_SIMULATE_ID@") set(CMAKE_Fortran_SIMULATE_VERSION "@CMAKE_Fortran_SIMULATE_VERSION@") @_SET_CMAKE_Fortran_XL_CPP@ @_SET_CMAKE_Fortran_COMPILER_ARCHITECTURE_ID@ +@_SET_CMAKE_Fortran_COMPILER_SYSROOT@ @SET_MSVC_Fortran_ARCHITECTURE_ID@ set(CMAKE_AR "@CMAKE_AR@") set(CMAKE_Fortran_COMPILER_AR "@CMAKE_Fortran_COMPILER_AR@") diff --git a/Modules/CMakePrintSystemInformation.cmake b/Modules/CMakePrintSystemInformation.cmake index 8d5cf5c..d44e933 100644 --- a/Modules/CMakePrintSystemInformation.cmake +++ b/Modules/CMakePrintSystemInformation.cmake @@ -11,7 +11,7 @@ This module serves diagnostic purposes. Just include it in a project to see various internal CMake variables. #]=======================================================================] -message("CMAKE_SYSTEM is ${CMAKE_SYSTEM} ${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_VERSION}") +message("CMAKE_SYSTEM is ${CMAKE_SYSTEM} ${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_VERSION} ${CMAKE_SYSTEM_PROCESSOR}") message("CMAKE_SYSTEM file is ${CMAKE_SYSTEM_INFO_FILE}") message("CMAKE_C_COMPILER is ${CMAKE_C_COMPILER}") message("CMAKE_CXX_COMPILER is ${CMAKE_CXX_COMPILER}") diff --git a/Modules/FindCUDAToolkit.cmake b/Modules/FindCUDAToolkit.cmake index eed1d81..8d20ff9 100644 --- a/Modules/FindCUDAToolkit.cmake +++ b/Modules/FindCUDAToolkit.cmake @@ -711,8 +711,15 @@ find_path(CUDAToolkit_INCLUDE_DIR # And find the CUDA Runtime Library libcudart find_library(CUDA_CUDART NAMES cudart - PATH_SUFFIXES lib64 lib64/stubs lib/x64 + PATH_SUFFIXES lib64 lib/x64 ) +if (NOT CUDA_CUDART) + find_library(CUDA_CUDART + NAMES cudart + PATH_SUFFIXES lib64/stubs lib/x64/stubs + ) +endif() + if (NOT CUDA_CUDART AND NOT CUDAToolkit_FIND_QUIETLY) message(STATUS "Unable to find cudart library.") endif() @@ -759,9 +766,20 @@ if(CUDAToolkit_FOUND) NAMES ${search_names} HINTS ${CUDAToolkit_LIBRARY_DIR} ENV CUDA_PATH - PATH_SUFFIXES nvidia/current lib64 lib64/stubs lib/x64 lib lib/stubs + PATH_SUFFIXES nvidia/current lib64 lib/x64 lib ${arg_EXTRA_PATH_SUFFIXES} ) + # Don't try any stub directories intil we have exhausted all other + # search locations. + if(NOT CUDA_${lib_name}_LIBRARY) + find_library(CUDA_${lib_name}_LIBRARY + NAMES ${search_names} + HINTS ${CUDAToolkit_LIBRARY_DIR} + ENV CUDA_PATH + PATH_SUFFIXES lib64/stubs lib/x64/stubs lib/stubs stubs + ) + endif() + mark_as_advanced(CUDA_${lib_name}_LIBRARY) if (NOT TARGET CUDA::${lib_name} AND CUDA_${lib_name}_LIBRARY) diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake index 5467b77..a990f0d 100644 --- a/Modules/FindPython/Support.cmake +++ b/Modules/FindPython/Support.cmake @@ -450,7 +450,7 @@ function (_PYTHON_GET_VERSION) set (${_PGV_PREFIX}VERSION_PATCH ${version_patch} PARENT_SCOPE) # compute ABI flags - if (version_major VERSION_GREATER 2) + if (version_major VERSION_GREATER "2") file (STRINGS "${_${_PYTHON_PREFIX}_INCLUDE_DIR}/pyconfig.h" config REGEX "(Py_DEBUG|WITH_PYMALLOC|Py_UNICODE_SIZE|MS_WIN32)") set (abi) if (config MATCHES "#[ ]*define[ ]+MS_WIN32") @@ -823,7 +823,7 @@ endif() # Set ABIs to search ## default: search any ABI -if (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR VERSION_LESS 3) +if (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR VERSION_LESS "3") # ABI not supported unset (_${_PYTHON_PREFIX}_FIND_ABI) set (_${_PYTHON_PREFIX}_ABIFLAGS "") @@ -1409,7 +1409,7 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) unset (${_PYTHON_PREFIX}_SITEARCH) endif() - if (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR VERSION_GREATER_EQUAL 3) + if (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR VERSION_GREATER_EQUAL "3") _python_get_config_var (${_PYTHON_PREFIX}_SOABI SOABI) endif() @@ -1601,7 +1601,7 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) if (_${_PYTHON_PREFIX}_COMPILER AND _${_PYTHON_PREFIX}_COMPILER_USABLE) if (${_PYTHON_PREFIX}_Interpreter_FOUND) # Compiler must be compatible with interpreter - if (${_${_PYTHON_PREFIX}_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_VERSION_MINOR} VERSION_EQUAL ${${_PYTHON_PREFIX}_VERSION_MAJOR}.${${_PYTHON_PREFIX}_VERSION_MINOR}) + if ("${_${_PYTHON_PREFIX}_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_VERSION_MINOR}" VERSION_EQUAL "${${_PYTHON_PREFIX}_VERSION_MAJOR}.${${_PYTHON_PREFIX}_VERSION_MINOR}") set (${_PYTHON_PREFIX}_Compiler_FOUND TRUE) endif() elseif (${_PYTHON_PREFIX}_VERSION_MAJOR VERSION_EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR) @@ -2242,7 +2242,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS _python_get_version (INCLUDE PREFIX _${_PYTHON_PREFIX}_INC_) # update versioning - if (_${_PYTHON_PREFIX}_INC_VERSION VERSION_EQUAL ${_${_PYTHON_PREFIX}_VERSION}) + if (_${_PYTHON_PREFIX}_INC_VERSION VERSION_EQUAL _${_PYTHON_PREFIX}_VERSION) set (_${_PYTHON_PREFIX}_VERSION_PATCH ${_${_PYTHON_PREFIX}_INC_VERSION_PATCH}) endif() endif() @@ -2284,12 +2284,12 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE AND _${_PYTHON_PREFIX}_INCLUDE_DIR) if (${_PYTHON_PREFIX}_Interpreter_FOUND OR ${_PYTHON_PREFIX}_Compiler_FOUND) # development environment must be compatible with interpreter/compiler - if (${_${_PYTHON_PREFIX}_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_VERSION_MINOR} VERSION_EQUAL ${${_PYTHON_PREFIX}_VERSION_MAJOR}.${${_PYTHON_PREFIX}_VERSION_MINOR} - AND ${_${_PYTHON_PREFIX}_INC_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_INC_VERSION_MINOR} VERSION_EQUAL ${_${_PYTHON_PREFIX}_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_VERSION_MINOR}) + if ("${_${_PYTHON_PREFIX}_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_VERSION_MINOR}" VERSION_EQUAL "${${_PYTHON_PREFIX}_VERSION_MAJOR}.${${_PYTHON_PREFIX}_VERSION_MINOR}" + AND "${_${_PYTHON_PREFIX}_INC_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_INC_VERSION_MINOR}" VERSION_EQUAL "${_${_PYTHON_PREFIX}_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_VERSION_MINOR}") set (${_PYTHON_PREFIX}_Development_FOUND TRUE) endif() elseif (${_PYTHON_PREFIX}_VERSION_MAJOR VERSION_EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR - AND ${_${_PYTHON_PREFIX}_INC_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_INC_VERSION_MINOR} VERSION_EQUAL ${_${_PYTHON_PREFIX}_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_VERSION_MINOR}) + AND "${_${_PYTHON_PREFIX}_INC_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_INC_VERSION_MINOR}" VERSION_EQUAL "${_${_PYTHON_PREFIX}_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_VERSION_MINOR}") set (${_PYTHON_PREFIX}_Development_FOUND TRUE) endif() if (DEFINED _${_PYTHON_PREFIX}_FIND_ABI AND @@ -2299,7 +2299,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS endif() endif() - if (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR VERSION_GREATER_EQUAL 3 + if (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR VERSION_GREATER_EQUAL "3" AND NOT DEFINED ${_PYTHON_PREFIX}_SOABI) _python_get_config_var (${_PYTHON_PREFIX}_SOABI SOABI) endif() diff --git a/Modules/Internal/CPack/NSIS.template.in b/Modules/Internal/CPack/NSIS.template.in index 660bfa3..6009ce0 100644 --- a/Modules/Internal/CPack/NSIS.template.in +++ b/Modules/Internal/CPack/NSIS.template.in @@ -41,6 +41,7 @@ RequestExecutionLevel admin @CPACK_NSIS_DEFINES@ +@CPACK_NSIS_MANIFEST_DPI_AWARE_CODE@ !include Sections.nsh diff --git a/Modules/Platform/UnixPaths.cmake b/Modules/Platform/UnixPaths.cmake index 97f744d..98c83aa 100644 --- a/Modules/Platform/UnixPaths.cmake +++ b/Modules/Platform/UnixPaths.cmake @@ -86,6 +86,10 @@ set(_CMAKE_CUDA_IMPLICIT_INCLUDE_DIRECTORIES_INIT unset(_cmake_sysroot_compile) +if(CMAKE_COMPILER_SYSROOT) + list(PREPEND CMAKE_SYSTEM_PREFIX_PATH "${CMAKE_COMPILER_SYSROOT}") +endif() + # Enable use of lib32 and lib64 search path variants by default. set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS TRUE) set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS TRUE) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 2ce3006..56d9174 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 17) -set(CMake_VERSION_PATCH 20200415) +set(CMake_VERSION_PATCH 20200416) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index 9afdc62..3067f96 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -203,6 +203,11 @@ int cmCPackNSISGenerator::PackageFiles() "!define MUI_FINISHPAGE_TITLE_3LINES"); } + if (this->IsSet("CPACK_NSIS_MANIFEST_DPI_AWARE")) { + this->SetOptionIfNotSet("CPACK_NSIS_MANIFEST_DPI_AWARE_CODE", + "ManifestDPIAware true"); + } + // Setup all of the component sections if (this->Components.empty()) { this->SetOptionIfNotSet("CPACK_NSIS_INSTALLATION_TYPES", ""); diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index 874efa5..697d435 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -580,7 +580,8 @@ const char* CCONV cmSourceFileGetProperty(void* arg, const char* prop) { cmCPluginAPISourceFile* sf = static_cast<cmCPluginAPISourceFile*>(arg); if (cmSourceFile* rsf = sf->RealSourceFile) { - return rsf->GetProperty(prop); + cmProp p = rsf->GetProperty(prop); + return p ? p->c_str() : nullptr; } if (!strcmp(prop, "LOCATION")) { return sf->FullPath.c_str(); diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 939f757..673936c 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -73,9 +73,9 @@ void cmCommonTargetGenerator::AddModuleDefinitionFlag( void cmCommonTargetGenerator::AppendFortranFormatFlags( std::string& flags, cmSourceFile const& source) { - const char* srcfmt = source.GetProperty("Fortran_FORMAT"); + cmProp srcfmt = source.GetProperty("Fortran_FORMAT"); cmOutputConverter::FortranFormat format = - cmOutputConverter::GetFortranFormat(srcfmt); + cmOutputConverter::GetFortranFormat(srcfmt ? srcfmt->c_str() : nullptr); if (format == cmOutputConverter::FortranFormatNone) { const char* tgtfmt = this->GeneratorTarget->GetProperty("Fortran_FORMAT"); format = cmOutputConverter::GetFortranFormat(tgtfmt); diff --git a/Source/cmCustomCommand.cxx b/Source/cmCustomCommand.cxx index 0dd8722..149f5e9 100644 --- a/Source/cmCustomCommand.cxx +++ b/Source/cmCustomCommand.cxx @@ -11,7 +11,8 @@ cmCustomCommand::cmCustomCommand(std::vector<std::string> outputs, std::vector<std::string> depends, cmCustomCommandLines commandLines, cmListFileBacktrace lfbt, const char* comment, - const char* workingDirectory) + const char* workingDirectory, + bool stdPipesUTF8) : Outputs(std::move(outputs)) , Byproducts(std::move(byproducts)) , Depends(std::move(depends)) @@ -20,6 +21,7 @@ cmCustomCommand::cmCustomCommand(std::vector<std::string> outputs, , Comment(comment ? comment : "") , WorkingDirectory(workingDirectory ? workingDirectory : "") , HaveComment(comment != nullptr) + , StdPipesUTF8(stdPipesUTF8) { } diff --git a/Source/cmCustomCommand.h b/Source/cmCustomCommand.h index d300fa5..aa572ad 100644 --- a/Source/cmCustomCommand.h +++ b/Source/cmCustomCommand.h @@ -30,7 +30,8 @@ public: std::vector<std::string> byproducts, std::vector<std::string> depends, cmCustomCommandLines commandLines, cmListFileBacktrace lfbt, - const char* comment, const char* workingDirectory); + const char* comment, const char* workingDirectory, + bool stdPipesUTF8); /** Get the output file produced by the command. */ const std::vector<std::string>& GetOutputs() const; @@ -53,6 +54,9 @@ public: /** Get the comment string for the command. */ const char* GetComment() const; + /** Get a value indicating if the command uses UTF-8 output pipes. */ + bool GetStdPipesUTF8() const { return this->StdPipesUTF8; } + /** Append to the list of command lines. */ void AppendCommands(const cmCustomCommandLines& commandLines); @@ -108,6 +112,7 @@ private: bool EscapeOldStyle = true; bool UsesTerminal = false; bool CommandExpandLists = false; + bool StdPipesUTF8 = false; }; #endif diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 5b136e2..6dbc7b7 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -23,6 +23,8 @@ #include "cmSystemTools.h" #include "cmake.h" +using cmProp = const std::string*; // just to silence IWYU + /* Sublime Text 2 Generator Author: Morné Chamberlain @@ -358,14 +360,14 @@ std::string cmExtraSublimeTextGenerator::ComputeFlagsForObject( language); const std::string COMPILE_FLAGS("COMPILE_FLAGS"); - if (const char* cflags = source->GetProperty(COMPILE_FLAGS)) { - lg->AppendFlags(flags, genexInterpreter.Evaluate(cflags, COMPILE_FLAGS)); + if (cmProp cflags = source->GetProperty(COMPILE_FLAGS)) { + lg->AppendFlags(flags, genexInterpreter.Evaluate(*cflags, COMPILE_FLAGS)); } const std::string COMPILE_OPTIONS("COMPILE_OPTIONS"); - if (const char* coptions = source->GetProperty(COMPILE_OPTIONS)) { + if (cmProp coptions = source->GetProperty(COMPILE_OPTIONS)) { lg->AppendCompileOptions( - flags, genexInterpreter.Evaluate(coptions, COMPILE_OPTIONS)); + flags, genexInterpreter.Evaluate(*coptions, COMPILE_OPTIONS)); } return flags; @@ -387,17 +389,17 @@ std::string cmExtraSublimeTextGenerator::ComputeDefines( // Add preprocessor definitions for this target and configuration. lg->GetTargetDefines(target, config, language, defines); const std::string COMPILE_DEFINITIONS("COMPILE_DEFINITIONS"); - if (const char* compile_defs = source->GetProperty(COMPILE_DEFINITIONS)) { + if (cmProp compile_defs = source->GetProperty(COMPILE_DEFINITIONS)) { lg->AppendDefines( - defines, genexInterpreter.Evaluate(compile_defs, COMPILE_DEFINITIONS)); + defines, genexInterpreter.Evaluate(*compile_defs, COMPILE_DEFINITIONS)); } std::string defPropName = cmStrCat("COMPILE_DEFINITIONS_", cmSystemTools::UpperCase(config)); - if (const char* config_compile_defs = source->GetProperty(defPropName)) { + if (cmProp config_compile_defs = source->GetProperty(defPropName)) { lg->AppendDefines( defines, - genexInterpreter.Evaluate(config_compile_defs, COMPILE_DEFINITIONS)); + genexInterpreter.Evaluate(*config_compile_defs, COMPILE_DEFINITIONS)); } std::string definesString; @@ -419,9 +421,9 @@ std::string cmExtraSublimeTextGenerator::ComputeIncludes( // Add include directories for this source file const std::string INCLUDE_DIRECTORIES("INCLUDE_DIRECTORIES"); - if (const char* cincludes = source->GetProperty(INCLUDE_DIRECTORIES)) { + if (cmProp cincludes = source->GetProperty(INCLUDE_DIRECTORIES)) { lg->AppendIncludeDirectories( - includes, genexInterpreter.Evaluate(cincludes, INCLUDE_DIRECTORIES), + includes, genexInterpreter.Evaluate(*cincludes, INCLUDE_DIRECTORIES), *source); } diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx index 70f5847..f4237cb 100644 --- a/Source/cmFileAPICodemodel.cxx +++ b/Source/cmFileAPICodemodel.cxx @@ -855,8 +855,8 @@ CompileData Target::BuildCompileData(cmSourceFile* sf) fd.Language); const std::string COMPILE_FLAGS("COMPILE_FLAGS"); - if (const char* cflags = sf->GetProperty(COMPILE_FLAGS)) { - std::string flags = genexInterpreter.Evaluate(cflags, COMPILE_FLAGS); + if (cmProp cflags = sf->GetProperty(COMPILE_FLAGS)) { + std::string flags = genexInterpreter.Evaluate(*cflags, COMPILE_FLAGS); fd.Flags.emplace_back(std::move(flags), JBTIndex()); } const std::string COMPILE_OPTIONS("COMPILE_OPTIONS"); @@ -949,10 +949,10 @@ CompileData Target::BuildCompileData(cmSourceFile* sf) std::set<std::string> configFileDefines; const std::string defPropName = "COMPILE_DEFINITIONS_" + cmSystemTools::UpperCase(this->Config); - if (const char* config_defs = sf->GetProperty(defPropName)) { + if (cmProp config_defs = sf->GetProperty(defPropName)) { lg->AppendDefines( configFileDefines, - genexInterpreter.Evaluate(config_defs, COMPILE_DEFINITIONS)); + genexInterpreter.Evaluate(*config_defs, COMPILE_DEFINITIONS)); } fd.Defines.reserve(fileDefines.size() + configFileDefines.size()); diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 93eb8fb..55157b4 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -2839,8 +2839,8 @@ void cmTargetTraceDependencies::Trace() this->CurrentEntry = &this->GeneratorTarget->SourceDepends[sf]; // Queue dependencies added explicitly by the user. - if (const char* additionalDeps = sf->GetProperty("OBJECT_DEPENDS")) { - std::vector<std::string> objDeps = cmExpandedList(additionalDeps); + if (cmProp additionalDeps = sf->GetProperty("OBJECT_DEPENDS")) { + std::vector<std::string> objDeps = cmExpandedList(*additionalDeps); for (std::string& objDep : objDeps) { if (cmSystemTools::FileIsFullPath(objDep)) { objDep = cmSystemTools::CollapseFullPath(objDep); @@ -4707,16 +4707,16 @@ cmGeneratorTarget::GetTargetSourceFileFlags(const cmSourceFile* sf) const } else { // Handle the MACOSX_PACKAGE_LOCATION property on source files that // were not listed in one of the other lists. - if (const char* location = sf->GetProperty("MACOSX_PACKAGE_LOCATION")) { - flags.MacFolder = location; + if (cmProp location = sf->GetProperty("MACOSX_PACKAGE_LOCATION")) { + flags.MacFolder = location->c_str(); const bool stripResources = this->GlobalGenerator->ShouldStripResourcePath(this->Makefile); - if (strcmp(location, "Resources") == 0) { + if (*location == "Resources") { flags.Type = cmGeneratorTarget::SourceFileTypeResource; if (stripResources) { flags.MacFolder = ""; } - } else if (cmHasLiteralPrefix(location, "Resources/")) { + } else if (cmHasLiteralPrefix(*location, "Resources/")) { flags.Type = cmGeneratorTarget::SourceFileTypeDeepResource; if (stripResources) { flags.MacFolder += strlen("Resources/"); diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index deb722f..f0c6d48 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -456,9 +456,9 @@ void cmGhsMultiTargetGenerator::WriteSourceProperty( std::ostream& fout, const cmSourceFile* sf, std::string const& propName, std::string const& propFlag) { - const char* prop = sf->GetProperty(propName); + cmProp prop = sf->GetProperty(propName); if (prop) { - std::vector<std::string> list = cmExpandedList(prop); + std::vector<std::string> list = cmExpandedList(*prop); for (const std::string& p : list) { fout << " " << propFlag << p << '\n'; } @@ -708,9 +708,9 @@ void cmGhsMultiTargetGenerator::WriteCustomCommandLine( void cmGhsMultiTargetGenerator::WriteObjectLangOverride( std::ostream& fout, const cmSourceFile* sourceFile) { - const char* rawLangProp = sourceFile->GetProperty("LANGUAGE"); + cmProp rawLangProp = sourceFile->GetProperty("LANGUAGE"); if (nullptr != rawLangProp) { - std::string sourceLangProp(rawLangProp); + std::string sourceLangProp(*rawLangProp); std::string const& extension = sourceFile->GetExtension(); if ("CXX" == sourceLangProp && ("c" == extension || "C" == extension)) { fout << " -dotciscxx\n"; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 4a6f6fb..8505d43 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2545,6 +2545,7 @@ void cmGlobalGenerator::AddGlobalTarget_EditCache( singleLine.push_back("No interactive CMake dialog available."); gti.Message = "No interactive CMake dialog available..."; gti.UsesTerminal = false; + gti.StdPipesUTF8 = true; } gti.CommandLines.push_back(std::move(singleLine)); @@ -2569,6 +2570,7 @@ void cmGlobalGenerator::AddGlobalTarget_RebuildCache( singleLine.push_back("-S$(CMAKE_SOURCE_DIR)"); singleLine.push_back("-B$(CMAKE_BINARY_DIR)"); gti.CommandLines.push_back(std::move(singleLine)); + gti.StdPipesUTF8 = true; targets.push_back(std::move(gti)); } @@ -2605,6 +2607,7 @@ void cmGlobalGenerator::AddGlobalTarget_Install( gti.Name = this->GetInstallTargetName(); gti.Message = "Install the project..."; gti.UsesTerminal = true; + gti.StdPipesUTF8 = true; cmCustomCommandLine singleLine; if (this->GetPreinstallTargetName()) { gti.Depends.emplace_back(this->GetPreinstallTargetName()); @@ -2716,7 +2719,8 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget(GlobalTargetInfo const& gti, std::vector<std::string> no_depends; // Store the custom command in the target. cmCustomCommand cc(no_outputs, no_byproducts, no_depends, gti.CommandLines, - cmListFileBacktrace(), nullptr, gti.WorkingDir.c_str()); + cmListFileBacktrace(), nullptr, gti.WorkingDir.c_str(), + gti.StdPipesUTF8); cc.SetUsesTerminal(gti.UsesTerminal); target.AddPostBuildCommand(std::move(cc)); if (!gti.Message.empty()) { @@ -3105,10 +3109,10 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target) std::string const& sfp = sf->ResolveFullPath(); fout << sfp << "\n"; lj_source["file"] = sfp; - if (const char* svalue = sf->GetProperty("LABELS")) { + if (cmProp svalue = sf->GetProperty("LABELS")) { labels.clear(); Json::Value& lj_source_labels = lj_source["labels"] = Json::arrayValue; - cmExpandList(svalue, labels); + cmExpandList(*svalue, labels); for (std::string const& label : labels) { fout << " " << label << "\n"; lj_source_labels.append(label); diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 70e43b5..a76ab3c 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -554,6 +554,7 @@ protected: std::string WorkingDir; bool UsesTerminal = false; bool PerConfig = true; + bool StdPipesUTF8 = false; }; void CreateDefaultGlobalTargets(std::vector<GlobalTargetInfo>& targets); diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index fa0e935..1df76ca 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -142,6 +142,9 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() // Add a custom rule to re-run CMake if any input files changed. { + // The custom rule runs cmake so set UTF-8 pipes. + bool stdPipesUTF8 = true; + // Collect the input files used to generate all targets in this // project. std::vector<std::string> listFiles; @@ -160,7 +163,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() lg.AddCustomCommandToTarget( CMAKE_CHECK_BUILD_SYSTEM_TARGET, byproducts, no_depends, verifyCommandLines, cmCustomCommandType::PRE_BUILD, - "Checking File Globs", no_working_directory, false); + "Checking File Globs", no_working_directory, stdPipesUTF8); // Ensure ZERO_CHECK always runs in Visual Studio using MSBuild, // otherwise the prebuild command will not be run. @@ -192,7 +195,8 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() if (cmSourceFile* file = lg.AddCustomCommandToOutput( stamps, no_byproducts, listFiles, no_main_dependency, no_implicit_depends, commandLines, "Checking Build System", - no_working_directory, true, false)) { + no_working_directory, true, false, false, false, "", "", + stdPipesUTF8)) { gt->AddSource(file->ResolveFullPath()); } else { cmSystemTools::Error("Error adding rule for " + stamps[0]); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index d2f9760..b9f4609 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -932,7 +932,7 @@ void cmGlobalVisualStudioGenerator::AddSymbolExportCommand( { cmakeCommand, "-E", "__create_def", mdi->DefFile, objs_file }); cmCustomCommand command(outputs, empty, empty, commandLines, gt->Target->GetMakefile()->GetBacktrace(), - "Auto build dll exports", "."); + "Auto build dll exports", ".", true); commands.push_back(std::move(command)); } diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index bdc03c7..c0068b4 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -770,11 +770,15 @@ public: XCodeGeneratorExpressionInterpreter& operator=( XCodeGeneratorExpressionInterpreter const&) = delete; - using cmGeneratorExpressionInterpreter::Evaluate; - const std::string& Evaluate(const char* expression, const std::string& property) { + return this->Evaluate(std::string(expression ? expression : ""), property); + } + + const std::string& Evaluate(const std::string& expression, + const std::string& property) + { const std::string& processed = this->cmGeneratorExpressionInterpreter::Evaluate(expression, property); if (this->CompiledGeneratorExpression->GetHadContextSensitiveCondition()) { @@ -805,8 +809,9 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile( // Add flags from target and source file properties. std::string flags; - const char* srcfmt = sf->GetProperty("Fortran_FORMAT"); - switch (cmOutputConverter::GetFortranFormat(srcfmt)) { + cmProp srcfmt = sf->GetProperty("Fortran_FORMAT"); + switch ( + cmOutputConverter::GetFortranFormat(srcfmt ? srcfmt->c_str() : nullptr)) { case cmOutputConverter::FortranFormatFixed: flags = "-fixed " + flags; break; @@ -817,22 +822,22 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile( break; } const std::string COMPILE_FLAGS("COMPILE_FLAGS"); - if (const char* cflags = sf->GetProperty(COMPILE_FLAGS)) { - lg->AppendFlags(flags, genexInterpreter.Evaluate(cflags, COMPILE_FLAGS)); + if (cmProp cflags = sf->GetProperty(COMPILE_FLAGS)) { + lg->AppendFlags(flags, genexInterpreter.Evaluate(*cflags, COMPILE_FLAGS)); } const std::string COMPILE_OPTIONS("COMPILE_OPTIONS"); - if (const char* coptions = sf->GetProperty(COMPILE_OPTIONS)) { + if (cmProp coptions = sf->GetProperty(COMPILE_OPTIONS)) { lg->AppendCompileOptions( - flags, genexInterpreter.Evaluate(coptions, COMPILE_OPTIONS)); + flags, genexInterpreter.Evaluate(*coptions, COMPILE_OPTIONS)); } // Add per-source definitions. BuildObjectListOrString flagsBuild(this, false); const std::string COMPILE_DEFINITIONS("COMPILE_DEFINITIONS"); - if (const char* compile_defs = sf->GetProperty(COMPILE_DEFINITIONS)) { + if (cmProp compile_defs = sf->GetProperty(COMPILE_DEFINITIONS)) { this->AppendDefines( flagsBuild, - genexInterpreter.Evaluate(compile_defs, COMPILE_DEFINITIONS).c_str(), + genexInterpreter.Evaluate(*compile_defs, COMPILE_DEFINITIONS).c_str(), true); } @@ -850,9 +855,9 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile( // Add per-source include directories. std::vector<std::string> includes; const std::string INCLUDE_DIRECTORIES("INCLUDE_DIRECTORIES"); - if (const char* cincludes = sf->GetProperty(INCLUDE_DIRECTORIES)) { + if (cmProp cincludes = sf->GetProperty(INCLUDE_DIRECTORIES)) { lg->AppendIncludeDirectories( - includes, genexInterpreter.Evaluate(cincludes, INCLUDE_DIRECTORIES), + includes, genexInterpreter.Evaluate(*cincludes, INCLUDE_DIRECTORIES), *sf); } lg->AppendFlags(flags, lg->GetIncludeFlags(includes, gtgt, lang, true)); @@ -881,10 +886,10 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile( } // Add user-specified file attributes. - const char* extraFileAttributes = sf->GetProperty("XCODE_FILE_ATTRIBUTES"); + cmProp extraFileAttributes = sf->GetProperty("XCODE_FILE_ATTRIBUTES"); if (extraFileAttributes) { // Expand the list of attributes. - std::vector<std::string> attributes = cmExpandedList(extraFileAttributes); + std::vector<std::string> attributes = cmExpandedList(*extraFileAttributes); // Store the attributes. for (const auto& attribute : attributes) { @@ -995,11 +1000,11 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeFileReferenceFromPath( bool useLastKnownFileType = false; std::string fileType; if (sf) { - if (const char* e = sf->GetProperty("XCODE_EXPLICIT_FILE_TYPE")) { - fileType = e; - } else if (const char* l = sf->GetProperty("XCODE_LAST_KNOWN_FILE_TYPE")) { + if (cmProp e = sf->GetProperty("XCODE_EXPLICIT_FILE_TYPE")) { + fileType = *e; + } else if (cmProp l = sf->GetProperty("XCODE_LAST_KNOWN_FILE_TYPE")) { useLastKnownFileType = true; - fileType = l; + fileType = *l; } } if (fileType.empty()) { @@ -1464,6 +1469,7 @@ void cmGlobalXCodeGenerator::CreateCustomCommands( cmStrCat("$<TARGET_SONAME_FILE:", gtgt->GetName(), '>'); std::string str_link_file = cmStrCat("$<TARGET_LINKER_FILE:", gtgt->GetName(), '>'); + bool stdPipesUTF8 = true; cmCustomCommandLines cmd = cmMakeSingleCommandLine( { cmSystemTools::GetCMakeCommand(), "-E", "cmake_symlink_library", str_file, str_so_file, str_link_file }); @@ -1471,7 +1477,7 @@ void cmGlobalXCodeGenerator::CreateCustomCommands( cmCustomCommand command( std::vector<std::string>(), std::vector<std::string>(), std::vector<std::string>(), cmd, this->CurrentMakefile->GetBacktrace(), - "Creating symlinks", ""); + "Creating symlinks", "", stdPipesUTF8); postbuild.push_back(std::move(command)); } diff --git a/Source/cmJsonObjects.cxx b/Source/cmJsonObjects.cxx index 9ecf378..a4f78bc 100644 --- a/Source/cmJsonObjects.cxx +++ b/Source/cmJsonObjects.cxx @@ -275,14 +275,14 @@ static Json::Value DumpSourceFilesList( std::string compileFlags = ld.Flags; const std::string COMPILE_FLAGS("COMPILE_FLAGS"); - if (const char* cflags = file->GetProperty(COMPILE_FLAGS)) { + if (cmProp cflags = file->GetProperty(COMPILE_FLAGS)) { lg->AppendFlags(compileFlags, - genexInterpreter.Evaluate(cflags, COMPILE_FLAGS)); + genexInterpreter.Evaluate(*cflags, COMPILE_FLAGS)); } const std::string COMPILE_OPTIONS("COMPILE_OPTIONS"); - if (const char* coptions = file->GetProperty(COMPILE_OPTIONS)) { + if (cmProp coptions = file->GetProperty(COMPILE_OPTIONS)) { lg->AppendCompileOptions( - compileFlags, genexInterpreter.Evaluate(coptions, COMPILE_OPTIONS)); + compileFlags, genexInterpreter.Evaluate(*coptions, COMPILE_OPTIONS)); } fileData.Flags = compileFlags; @@ -290,9 +290,9 @@ static Json::Value DumpSourceFilesList( std::vector<std::string> includes; const std::string INCLUDE_DIRECTORIES("INCLUDE_DIRECTORIES"); - if (const char* cincludes = file->GetProperty(INCLUDE_DIRECTORIES)) { + if (cmProp cincludes = file->GetProperty(INCLUDE_DIRECTORIES)) { const std::string& evaluatedIncludes = - genexInterpreter.Evaluate(cincludes, INCLUDE_DIRECTORIES); + genexInterpreter.Evaluate(*cincludes, INCLUDE_DIRECTORIES); lg->AppendIncludeDirectories(includes, evaluatedIncludes, *file); for (const auto& include : includes) { @@ -309,17 +309,17 @@ static Json::Value DumpSourceFilesList( const std::string COMPILE_DEFINITIONS("COMPILE_DEFINITIONS"); std::set<std::string> defines; - if (const char* defs = file->GetProperty(COMPILE_DEFINITIONS)) { + if (cmProp defs = file->GetProperty(COMPILE_DEFINITIONS)) { lg->AppendDefines( - defines, genexInterpreter.Evaluate(defs, COMPILE_DEFINITIONS)); + defines, genexInterpreter.Evaluate(*defs, COMPILE_DEFINITIONS)); } const std::string defPropName = "COMPILE_DEFINITIONS_" + cmSystemTools::UpperCase(config); - if (const char* config_defs = file->GetProperty(defPropName)) { + if (cmProp config_defs = file->GetProperty(defPropName)) { lg->AppendDefines( defines, - genexInterpreter.Evaluate(config_defs, COMPILE_DEFINITIONS)); + genexInterpreter.Evaluate(*config_defs, COMPILE_DEFINITIONS)); } defines.insert(ld.Defines.begin(), ld.Defines.end()); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index e6083d3..a55e094 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1089,7 +1089,8 @@ cmTarget* cmLocalGenerator::AddCustomCommandToTarget( const cmCustomCommandLines& commandLines, cmCustomCommandType type, const char* comment, const char* workingDir, bool escapeOldStyle, bool uses_terminal, const std::string& depfile, const std::string& job_pool, - bool command_expand_lists, cmObjectLibraryCommands objLibCommands) + bool command_expand_lists, cmObjectLibraryCommands objLibCommands, + bool stdPipesUTF8) { cmTarget* t = this->Makefile->GetCustomCommandTarget( target, objLibCommands, this->DirectoryBacktrace); @@ -1100,7 +1101,7 @@ cmTarget* cmLocalGenerator::AddCustomCommandToTarget( detail::AddCustomCommandToTarget( *this, this->DirectoryBacktrace, cmCommandOrigin::Generator, t, byproducts, depends, commandLines, type, comment, workingDir, escapeOldStyle, - uses_terminal, depfile, job_pool, command_expand_lists); + uses_terminal, depfile, job_pool, command_expand_lists, stdPipesUTF8); return t; } @@ -1110,14 +1111,14 @@ cmSourceFile* cmLocalGenerator::AddCustomCommandToOutput( const std::string& main_dependency, const cmCustomCommandLines& commandLines, const char* comment, const char* workingDir, bool replace, bool escapeOldStyle, bool uses_terminal, bool command_expand_lists, - const std::string& depfile, const std::string& job_pool) + const std::string& depfile, const std::string& job_pool, bool stdPipesUTF8) { std::vector<std::string> no_byproducts; cmImplicitDependsList no_implicit_depends; return this->AddCustomCommandToOutput( { output }, no_byproducts, depends, main_dependency, no_implicit_depends, commandLines, comment, workingDir, replace, escapeOldStyle, uses_terminal, - command_expand_lists, depfile, job_pool); + command_expand_lists, depfile, job_pool, stdPipesUTF8); } cmSourceFile* cmLocalGenerator::AddCustomCommandToOutput( @@ -1128,7 +1129,7 @@ cmSourceFile* cmLocalGenerator::AddCustomCommandToOutput( const cmCustomCommandLines& commandLines, const char* comment, const char* workingDir, bool replace, bool escapeOldStyle, bool uses_terminal, bool command_expand_lists, const std::string& depfile, - const std::string& job_pool) + const std::string& job_pool, bool stdPipesUTF8) { // Make sure there is at least one output. if (outputs.empty()) { @@ -1140,7 +1141,7 @@ cmSourceFile* cmLocalGenerator::AddCustomCommandToOutput( *this, this->DirectoryBacktrace, cmCommandOrigin::Generator, outputs, byproducts, depends, main_dependency, implicit_depends, commandLines, comment, workingDir, replace, escapeOldStyle, uses_terminal, - command_expand_lists, depfile, job_pool); + command_expand_lists, depfile, job_pool, stdPipesUTF8); } cmTarget* cmLocalGenerator::AddUtilityCommand( @@ -1149,7 +1150,7 @@ cmTarget* cmLocalGenerator::AddUtilityCommand( const std::vector<std::string>& depends, const cmCustomCommandLines& commandLines, bool escapeOldStyle, const char* comment, bool uses_terminal, bool command_expand_lists, - const std::string& job_pool) + const std::string& job_pool, bool stdPipesUTF8) { cmTarget* target = this->Makefile->AddNewUtilityTarget(utilityName, excludeFromAll); @@ -1163,7 +1164,7 @@ cmTarget* cmLocalGenerator::AddUtilityCommand( *this, this->DirectoryBacktrace, cmCommandOrigin::Generator, target, this->Makefile->GetUtilityOutput(target), workingDir, byproducts, depends, commandLines, escapeOldStyle, comment, uses_terminal, command_expand_lists, - job_pool); + job_pool, stdPipesUTF8); return target; } @@ -2648,6 +2649,7 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target) file << "endif()\n"; } + bool stdPipesUTF8 = true; cmCustomCommandLines commandLines = cmMakeSingleCommandLine( { cmSystemTools::GetCMakeCommand(), cmStrCat("-DPDB_PREFIX=", pdb_prefix), "-P", @@ -2666,14 +2668,16 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target) if (this->GetGlobalGenerator()->IsVisualStudio()) { this->AddCustomCommandToTarget( target->GetName(), outputs, no_deps, commandLines, - cmCustomCommandType::PRE_BUILD, no_message, - no_current_dir); + cmCustomCommandType::PRE_BUILD, no_message, no_current_dir, + true, false, "", "", false, + cmObjectLibraryCommands::Reject, stdPipesUTF8); } else { cmImplicitDependsList no_implicit_depends; cmSourceFile* copy_rule = this->AddCustomCommandToOutput( outputs, no_byproducts, no_deps, no_main_dependency, no_implicit_depends, commandLines, no_message, - no_current_dir); + no_current_dir, false, true, false, false, "", "", + stdPipesUTF8); if (copy_rule) { target->AddSource(copy_rule->ResolveFullPath()); @@ -3410,12 +3414,12 @@ std::string cmLocalGenerator::GetObjectFileNameWithoutTarget( // Ensure that for the CMakeFiles/<target>.dir/generated_source_file // we don't end up having: // CMakeFiles/<target>.dir/CMakeFiles/<target>.dir/generated_source_file.obj - const char* unitySourceFile = source.GetProperty("UNITY_SOURCE_FILE"); - const char* pchExtension = source.GetProperty("PCH_EXTENSION"); + cmProp unitySourceFile = source.GetProperty("UNITY_SOURCE_FILE"); + cmProp psExtension = source.GetProperty("PCH_EXTENSION"); const bool isPchObject = objectName.find("cmake_pch") != std::string::npos; - if (unitySourceFile || pchExtension || isPchObject) { - if (pchExtension) { - customOutputExtension = pchExtension; + if (unitySourceFile || psExtension || isPchObject) { + if (psExtension) { + customOutputExtension = psExtension->c_str(); } cmsys::RegularExpression var("(CMakeFiles/[^/]+.dir/)"); @@ -3730,7 +3734,7 @@ cmSourceFile* AddCustomCommand( const cmCustomCommandLines& commandLines, const char* comment, const char* workingDir, bool replace, bool escapeOldStyle, bool uses_terminal, bool command_expand_lists, const std::string& depfile, - const std::string& job_pool) + const std::string& job_pool, bool stdPipesUTF8) { cmMakefile* mf = lg.GetMakefile(); @@ -3792,7 +3796,8 @@ cmSourceFile* AddCustomCommand( } std::unique_ptr<cmCustomCommand> cc = cm::make_unique<cmCustomCommand>( - outputs, byproducts, depends2, commandLines, lfbt, comment, workingDir); + outputs, byproducts, depends2, commandLines, lfbt, comment, workingDir, + stdPipesUTF8); cc->SetEscapeOldStyle(escapeOldStyle); cc->SetEscapeAllowMakeVars(true); cc->SetImplicitDepends(implicit_depends); @@ -3819,7 +3824,7 @@ void AddCustomCommandToTarget(cmLocalGenerator& lg, const char* workingDir, bool escapeOldStyle, bool uses_terminal, const std::string& depfile, const std::string& job_pool, - bool command_expand_lists) + bool command_expand_lists, bool stdPipesUTF8) { cmMakefile* mf = lg.GetMakefile(); @@ -3829,7 +3834,7 @@ void AddCustomCommandToTarget(cmLocalGenerator& lg, // Add the command to the appropriate build step for the target. std::vector<std::string> no_output; cmCustomCommand cc(no_output, byproducts, depends, commandLines, lfbt, - comment, workingDir); + comment, workingDir, stdPipesUTF8); cc.SetEscapeOldStyle(escapeOldStyle); cc.SetEscapeAllowMakeVars(true); cc.SetUsesTerminal(uses_terminal); @@ -3860,7 +3865,7 @@ cmSourceFile* AddCustomCommandToOutput( const cmCustomCommandLines& commandLines, const char* comment, const char* workingDir, bool replace, bool escapeOldStyle, bool uses_terminal, bool command_expand_lists, const std::string& depfile, - const std::string& job_pool) + const std::string& job_pool, bool stdPipesUTF8) { // Always create the output sources and mark them generated. CreateGeneratedSources(lg, outputs, origin, lfbt); @@ -3869,7 +3874,7 @@ cmSourceFile* AddCustomCommandToOutput( return AddCustomCommand( lg, lfbt, outputs, byproducts, depends, main_dependency, implicit_depends, commandLines, comment, workingDir, replace, escapeOldStyle, uses_terminal, - command_expand_lists, depfile, job_pool); + command_expand_lists, depfile, job_pool, stdPipesUTF8); } void AppendCustomCommandToOutput(cmLocalGenerator& lg, @@ -3905,7 +3910,7 @@ void AddUtilityCommand(cmLocalGenerator& lg, const cmListFileBacktrace& lfbt, const cmCustomCommandLines& commandLines, bool escapeOldStyle, const char* comment, bool uses_terminal, bool command_expand_lists, - const std::string& job_pool) + const std::string& job_pool, bool stdPipesUTF8) { // Always create the byproduct sources and mark them generated. CreateGeneratedSource(lg, force.Name, origin, lfbt); @@ -3922,7 +3927,7 @@ void AddUtilityCommand(cmLocalGenerator& lg, const cmListFileBacktrace& lfbt, lg, lfbt, { force.Name }, byproducts, depends, no_main_dependency, no_implicit_depends, commandLines, comment, workingDir, /*replace=*/false, escapeOldStyle, uses_terminal, command_expand_lists, /*depfile=*/"", - job_pool); + job_pool, stdPipesUTF8); if (rule) { lg.GetMakefile()->AddTargetByproducts(target, byproducts); } diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 71cc63e..5fb9337 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -297,7 +297,8 @@ public: const char* comment, const char* workingDir, bool escapeOldStyle = true, bool uses_terminal = false, const std::string& depfile = "", const std::string& job_pool = "", bool command_expand_lists = false, - cmObjectLibraryCommands objLibCommands = cmObjectLibraryCommands::Reject); + cmObjectLibraryCommands objLibCommands = cmObjectLibraryCommands::Reject, + bool stdPipesUTF8 = false); /** * Add a custom command to a source file. @@ -308,7 +309,8 @@ public: const cmCustomCommandLines& commandLines, const char* comment, const char* workingDir, bool replace = false, bool escapeOldStyle = true, bool uses_terminal = false, bool command_expand_lists = false, - const std::string& depfile = "", const std::string& job_pool = ""); + const std::string& depfile = "", const std::string& job_pool = "", + bool stdPipesUTF8 = false); cmSourceFile* AddCustomCommandToOutput( const std::vector<std::string>& outputs, const std::vector<std::string>& byproducts, @@ -318,7 +320,8 @@ public: const cmCustomCommandLines& commandLines, const char* comment, const char* workingDir, bool replace = false, bool escapeOldStyle = true, bool uses_terminal = false, bool command_expand_lists = false, - const std::string& depfile = "", const std::string& job_pool = ""); + const std::string& depfile = "", const std::string& job_pool = "", + bool stdPipesUTF8 = false); /** * Add a utility to the build. A utility target is a command that is run @@ -330,7 +333,8 @@ public: const std::vector<std::string>& depends, const cmCustomCommandLines& commandLines, bool escapeOldStyle = true, const char* comment = nullptr, bool uses_terminal = false, - bool command_expand_lists = false, const std::string& job_pool = ""); + bool command_expand_lists = false, const std::string& job_pool = "", + bool stdPipesUTF8 = false); std::string GetProjectName() const; @@ -548,7 +552,7 @@ void AddCustomCommandToTarget(cmLocalGenerator& lg, const char* workingDir, bool escapeOldStyle, bool uses_terminal, const std::string& depfile, const std::string& job_pool, - bool command_expand_lists); + bool command_expand_lists, bool stdPipesUTF8); cmSourceFile* AddCustomCommandToOutput( cmLocalGenerator& lg, const cmListFileBacktrace& lfbt, @@ -559,7 +563,7 @@ cmSourceFile* AddCustomCommandToOutput( const cmCustomCommandLines& commandLines, const char* comment, const char* workingDir, bool replace, bool escapeOldStyle, bool uses_terminal, bool command_expand_lists, const std::string& depfile, - const std::string& job_pool); + const std::string& job_pool, bool stdPipesUTF8); void AppendCustomCommandToOutput(cmLocalGenerator& lg, const cmListFileBacktrace& lfbt, @@ -576,7 +580,7 @@ void AddUtilityCommand(cmLocalGenerator& lg, const cmListFileBacktrace& lfbt, const cmCustomCommandLines& commandLines, bool escapeOldStyle, const char* comment, bool uses_terminal, bool command_expand_lists, - const std::string& job_pool); + const std::string& job_pool, bool stdPipesUTF8); } #endif diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 9148b27..2dfdd1f 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -251,14 +251,15 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule() std::string argB = cmStrCat("-B", this->GetBinaryDirectory()); std::string stampName = cmStrCat(this->GetCurrentBinaryDirectory(), "/CMakeFiles/generate.stamp"); + bool stdPipesUTF8 = true; cmCustomCommandLines commandLines = cmMakeSingleCommandLine({ cmSystemTools::GetCMakeCommand(), argS, argB, "--check-stamp-file", stampName }); std::string comment = cmStrCat("Building Custom Rule ", makefileIn); const char* no_working_directory = nullptr; - this->AddCustomCommandToOutput(stampName, listFiles, makefileIn, - commandLines, comment.c_str(), - no_working_directory, true, false); + this->AddCustomCommandToOutput( + stampName, listFiles, makefileIn, commandLines, comment.c_str(), + no_working_directory, true, false, false, false, "", "", stdPipesUTF8); if (cmSourceFile* file = this->Makefile->GetSource(makefileIn)) { // Finalize the source file path now since we're adding this after // the generator validated all project-named sources. @@ -1445,14 +1446,15 @@ cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo( needfc = true; } const std::string COMPILE_FLAGS("COMPILE_FLAGS"); - if (const char* cflags = sf.GetProperty(COMPILE_FLAGS)) { - fc.CompileFlags = genexInterpreter.Evaluate(cflags, COMPILE_FLAGS); + if (cmProp cflags = sf.GetProperty(COMPILE_FLAGS)) { + fc.CompileFlags = genexInterpreter.Evaluate(*cflags, COMPILE_FLAGS); needfc = true; } const std::string COMPILE_OPTIONS("COMPILE_OPTIONS"); - if (const char* coptions = sf.GetProperty(COMPILE_OPTIONS)) { + if (cmProp coptions = sf.GetProperty(COMPILE_OPTIONS)) { lg->AppendCompileOptions( - fc.CompileFlags, genexInterpreter.Evaluate(coptions, COMPILE_OPTIONS)); + fc.CompileFlags, + genexInterpreter.Evaluate(*coptions, COMPILE_OPTIONS)); needfc = true; } // Add precompile headers compile options. @@ -1473,7 +1475,7 @@ cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo( if (lg->FortranProject) { switch (cmOutputConverter::GetFortranFormat( - sf.GetProperty("Fortran_FORMAT"))) { + sf.GetSafeProperty("Fortran_FORMAT"))) { case cmOutputConverter::FortranFormatFixed: fc.CompileFlags = "-fixed " + fc.CompileFlags; needfc = true; @@ -1487,26 +1489,26 @@ cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo( } } const std::string COMPILE_DEFINITIONS("COMPILE_DEFINITIONS"); - if (const char* cdefs = sf.GetProperty(COMPILE_DEFINITIONS)) { - fc.CompileDefs = genexInterpreter.Evaluate(cdefs, COMPILE_DEFINITIONS); + if (cmProp cdefs = sf.GetProperty(COMPILE_DEFINITIONS)) { + fc.CompileDefs = genexInterpreter.Evaluate(*cdefs, COMPILE_DEFINITIONS); needfc = true; } std::string defPropName = cmStrCat("COMPILE_DEFINITIONS_", configUpper); - if (const char* ccdefs = sf.GetProperty(defPropName)) { + if (cmProp ccdefs = sf.GetProperty(defPropName)) { fc.CompileDefsConfig = - genexInterpreter.Evaluate(ccdefs, COMPILE_DEFINITIONS); + genexInterpreter.Evaluate(*ccdefs, COMPILE_DEFINITIONS); needfc = true; } const std::string INCLUDE_DIRECTORIES("INCLUDE_DIRECTORIES"); - if (const char* cincs = sf.GetProperty(INCLUDE_DIRECTORIES)) { - fc.IncludeDirs = genexInterpreter.Evaluate(cincs, INCLUDE_DIRECTORIES); + if (cmProp cincs = sf.GetProperty(INCLUDE_DIRECTORIES)) { + fc.IncludeDirs = genexInterpreter.Evaluate(*cincs, INCLUDE_DIRECTORIES); needfc = true; } // Check for extra object-file dependencies. - if (const char* deps = sf.GetProperty("OBJECT_DEPENDS")) { - std::vector<std::string> depends = cmExpandedList(deps); + if (cmProp deps = sf.GetProperty("OBJECT_DEPENDS")) { + std::vector<std::string> depends = cmExpandedList(*deps); const char* sep = ""; for (const std::string& d : depends) { fc.AdditionalDeps += sep; diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index 7267976..ebd4f96 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -102,10 +102,12 @@ cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmGeneratorTarget* target, std::vector<std::string> no_output; std::vector<std::string> no_byproducts; std::vector<std::string> no_depends; + bool stdPipesUTF8 = true; cmCustomCommandLines commands = cmMakeSingleCommandLine( { cmSystemTools::GetCMakeCommand(), "-E", "make_directory", impDir }); pcc.reset(new cmCustomCommand(no_output, no_byproducts, no_depends, commands, - cmListFileBacktrace(), nullptr, nullptr)); + cmListFileBacktrace(), nullptr, nullptr, + stdPipesUTF8)); pcc->SetEscapeOldStyle(false); pcc->SetEscapeAllowMakeVars(true); return pcc; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 15b8b92..85e7df1 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1022,7 +1022,7 @@ cmTarget* cmMakefile::AddCustomCommandToTarget( const cmCustomCommandLines& commandLines, cmCustomCommandType type, const char* comment, const char* workingDir, bool escapeOldStyle, bool uses_terminal, const std::string& depfile, const std::string& job_pool, - bool command_expand_lists) + bool command_expand_lists, bool stdPipesUTF8) { cmTarget* t = this->GetCustomCommandTarget( target, cmObjectLibraryCommands::Reject, this->Backtrace); @@ -1040,14 +1040,15 @@ cmTarget* cmMakefile::AddCustomCommandToTarget( cm::optional<std::string> workingStr = MakeOptionalString(workingDir); // Dispatch command creation to allow generator expressions in outputs. - this->AddGeneratorAction([=](cmLocalGenerator& lg, - const cmListFileBacktrace& lfbt) { - BacktraceGuard guard(this->Backtrace, lfbt); - detail::AddCustomCommandToTarget( - lg, lfbt, cmCommandOrigin::Project, t, byproducts, depends, commandLines, - type, GetCStrOrNull(commentStr), GetCStrOrNull(workingStr), - escapeOldStyle, uses_terminal, depfile, job_pool, command_expand_lists); - }); + this->AddGeneratorAction( + [=](cmLocalGenerator& lg, const cmListFileBacktrace& lfbt) { + BacktraceGuard guard(this->Backtrace, lfbt); + detail::AddCustomCommandToTarget( + lg, lfbt, cmCommandOrigin::Project, t, byproducts, depends, + commandLines, type, GetCStrOrNull(commentStr), + GetCStrOrNull(workingStr), escapeOldStyle, uses_terminal, depfile, + job_pool, command_expand_lists, stdPipesUTF8); + }); return t; } @@ -1058,14 +1059,14 @@ void cmMakefile::AddCustomCommandToOutput( const char* comment, const char* workingDir, const CommandSourceCallback& callback, bool replace, bool escapeOldStyle, bool uses_terminal, bool command_expand_lists, const std::string& depfile, - const std::string& job_pool) + const std::string& job_pool, bool stdPipesUTF8) { std::vector<std::string> no_byproducts; cmImplicitDependsList no_implicit_depends; this->AddCustomCommandToOutput( { output }, no_byproducts, depends, main_dependency, no_implicit_depends, commandLines, comment, workingDir, callback, replace, escapeOldStyle, - uses_terminal, command_expand_lists, depfile, job_pool); + uses_terminal, command_expand_lists, depfile, job_pool, stdPipesUTF8); } void cmMakefile::AddCustomCommandToOutput( @@ -1076,7 +1077,7 @@ void cmMakefile::AddCustomCommandToOutput( const cmCustomCommandLines& commandLines, const char* comment, const char* workingDir, const CommandSourceCallback& callback, bool replace, bool escapeOldStyle, bool uses_terminal, bool command_expand_lists, - const std::string& depfile, const std::string& job_pool) + const std::string& depfile, const std::string& job_pool, bool stdPipesUTF8) { // Make sure there is at least one output. if (outputs.empty()) { @@ -1098,18 +1099,19 @@ void cmMakefile::AddCustomCommandToOutput( cm::optional<std::string> workingStr = MakeOptionalString(workingDir); // Dispatch command creation to allow generator expressions in outputs. - this->AddGeneratorAction([=](cmLocalGenerator& lg, - const cmListFileBacktrace& lfbt) { - BacktraceGuard guard(this->Backtrace, lfbt); - cmSourceFile* sf = detail::AddCustomCommandToOutput( - lg, lfbt, cmCommandOrigin::Project, outputs, byproducts, depends, - main_dependency, implicit_depends, commandLines, - GetCStrOrNull(commentStr), GetCStrOrNull(workingStr), replace, - escapeOldStyle, uses_terminal, command_expand_lists, depfile, job_pool); - if (callback && sf) { - callback(sf); - } - }); + this->AddGeneratorAction( + [=](cmLocalGenerator& lg, const cmListFileBacktrace& lfbt) { + BacktraceGuard guard(this->Backtrace, lfbt); + cmSourceFile* sf = detail::AddCustomCommandToOutput( + lg, lfbt, cmCommandOrigin::Project, outputs, byproducts, depends, + main_dependency, implicit_depends, commandLines, + GetCStrOrNull(commentStr), GetCStrOrNull(workingStr), replace, + escapeOldStyle, uses_terminal, command_expand_lists, depfile, job_pool, + stdPipesUTF8); + if (callback && sf) { + callback(sf); + } + }); } void cmMakefile::AddCustomCommandOldStyle( @@ -1225,7 +1227,7 @@ cmTarget* cmMakefile::AddUtilityCommand( const std::vector<std::string>& depends, const cmCustomCommandLines& commandLines, bool escapeOldStyle, const char* comment, bool uses_terminal, bool command_expand_lists, - const std::string& job_pool) + const std::string& job_pool, bool stdPipesUTF8) { cmTarget* target = this->AddNewUtilityTarget(utilityName, excludeFromAll); @@ -1254,7 +1256,7 @@ cmTarget* cmMakefile::AddUtilityCommand( force, GetCStrOrNull(workingStr), byproducts, depends, commandLines, escapeOldStyle, GetCStrOrNull(commentStr), uses_terminal, - command_expand_lists, job_pool); + command_expand_lists, job_pool, stdPipesUTF8); }); return target; diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 9a7eff9..04a1f2d 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -188,7 +188,8 @@ public: const cmCustomCommandLines& commandLines, cmCustomCommandType type, const char* comment, const char* workingDir, bool escapeOldStyle = true, bool uses_terminal = false, const std::string& depfile = "", - const std::string& job_pool = "", bool command_expand_lists = false); + const std::string& job_pool = "", bool command_expand_lists = false, + bool stdPipesUTF8 = false); /** * Called for each file with custom command. @@ -205,7 +206,8 @@ public: const char* workingDir, const CommandSourceCallback& callback = nullptr, bool replace = false, bool escapeOldStyle = true, bool uses_terminal = false, bool command_expand_lists = false, - const std::string& depfile = "", const std::string& job_pool = ""); + const std::string& depfile = "", const std::string& job_pool = "", + bool stdPipesUTF8 = false); void AddCustomCommandToOutput( const std::vector<std::string>& outputs, const std::vector<std::string>& byproducts, @@ -216,7 +218,8 @@ public: const char* workingDir, const CommandSourceCallback& callback = nullptr, bool replace = false, bool escapeOldStyle = true, bool uses_terminal = false, bool command_expand_lists = false, - const std::string& depfile = "", const std::string& job_pool = ""); + const std::string& depfile = "", const std::string& job_pool = "", + bool stdPipesUTF8 = false); void AddCustomCommandOldStyle(const std::string& target, const std::vector<std::string>& outputs, const std::vector<std::string>& depends, @@ -284,7 +287,8 @@ public: const std::vector<std::string>& depends, const cmCustomCommandLines& commandLines, bool escapeOldStyle = true, const char* comment = nullptr, bool uses_terminal = false, - bool command_expand_lists = false, const std::string& job_pool = ""); + bool command_expand_lists = false, const std::string& job_pool = "", + bool stdPipesUTF8 = false); /** * Add a subdirectory to the build. diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 5bb4c57..2d8f8d6 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -527,9 +527,9 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( // Add flags from source file properties. const std::string COMPILE_FLAGS("COMPILE_FLAGS"); - if (const char* cflags = source.GetProperty(COMPILE_FLAGS)) { + if (cmProp cflags = source.GetProperty(COMPILE_FLAGS)) { const std::string& evaluatedFlags = - genexInterpreter.Evaluate(cflags, COMPILE_FLAGS); + genexInterpreter.Evaluate(*cflags, COMPILE_FLAGS); this->LocalGenerator->AppendFlags(flags, evaluatedFlags); *this->FlagFileStream << "# Custom flags: " << relativeObj << "_FLAGS = " << evaluatedFlags << "\n" @@ -537,9 +537,9 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( } const std::string COMPILE_OPTIONS("COMPILE_OPTIONS"); - if (const char* coptions = source.GetProperty(COMPILE_OPTIONS)) { + if (cmProp coptions = source.GetProperty(COMPILE_OPTIONS)) { const std::string& evaluatedOptions = - genexInterpreter.Evaluate(coptions, COMPILE_OPTIONS); + genexInterpreter.Evaluate(*coptions, COMPILE_OPTIONS); this->LocalGenerator->AppendCompileOptions(flags, evaluatedOptions); *this->FlagFileStream << "# Custom options: " << relativeObj << "_OPTIONS = " << evaluatedOptions << "\n" @@ -571,9 +571,9 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( std::vector<std::string> includes; const std::string INCLUDE_DIRECTORIES("INCLUDE_DIRECTORIES"); - if (const char* cincludes = source.GetProperty(INCLUDE_DIRECTORIES)) { + if (cmProp cincludes = source.GetProperty(INCLUDE_DIRECTORIES)) { const std::string& evaluatedIncludes = - genexInterpreter.Evaluate(cincludes, INCLUDE_DIRECTORIES); + genexInterpreter.Evaluate(*cincludes, INCLUDE_DIRECTORIES); this->LocalGenerator->AppendIncludeDirectories(includes, evaluatedIncludes, source); *this->FlagFileStream << "# Custom include directories: " << relativeObj @@ -587,18 +587,18 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( // Add source-specific preprocessor definitions. const std::string COMPILE_DEFINITIONS("COMPILE_DEFINITIONS"); - if (const char* compile_defs = source.GetProperty(COMPILE_DEFINITIONS)) { + if (cmProp compile_defs = source.GetProperty(COMPILE_DEFINITIONS)) { const std::string& evaluatedDefs = - genexInterpreter.Evaluate(compile_defs, COMPILE_DEFINITIONS); + genexInterpreter.Evaluate(*compile_defs, COMPILE_DEFINITIONS); this->LocalGenerator->AppendDefines(defines, evaluatedDefs); *this->FlagFileStream << "# Custom defines: " << relativeObj << "_DEFINES = " << evaluatedDefs << "\n" << "\n"; } std::string defPropName = cmStrCat("COMPILE_DEFINITIONS_", configUpper); - if (const char* config_compile_defs = source.GetProperty(defPropName)) { + if (cmProp config_compile_defs = source.GetProperty(defPropName)) { const std::string& evaluatedDefs = - genexInterpreter.Evaluate(config_compile_defs, COMPILE_DEFINITIONS); + genexInterpreter.Evaluate(*config_compile_defs, COMPILE_DEFINITIONS); this->LocalGenerator->AppendDefines(defines, evaluatedDefs); *this->FlagFileStream << "# Custom defines: " << relativeObj << "_DEFINES_" << configUpper << " = " << evaluatedDefs << "\n" @@ -876,9 +876,9 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( // Check for extra outputs created by the compilation. std::vector<std::string> outputs(1, relativeObj); - if (const char* extra_outputs_str = source.GetProperty("OBJECT_OUTPUTS")) { + if (cmProp extra_outputs_str = source.GetProperty("OBJECT_OUTPUTS")) { // Register these as extra files to clean. - cmExpandList(extra_outputs_str, outputs); + cmExpandList(*extra_outputs_str, outputs); this->CleanFiles.insert(outputs.begin() + 1, outputs.end()); } @@ -1229,8 +1229,8 @@ void cmMakefileTargetGenerator::WriteObjectDependRules( // Create the list of dependencies known at cmake time. These are // shared between the object file and dependency scanning rule. depends.push_back(source.GetFullPath()); - if (const char* objectDeps = source.GetProperty("OBJECT_DEPENDS")) { - cmExpandList(objectDeps, depends); + if (cmProp objectDeps = source.GetProperty("OBJECT_DEPENDS")) { + cmExpandList(*objectDeps, depends); } } diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index ed74cf9..a70b6a0 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -190,15 +190,15 @@ std::string cmNinjaTargetGenerator::ComputeFlagsForObject( this->LocalGenerator, config, this->GeneratorTarget, language); const std::string COMPILE_FLAGS("COMPILE_FLAGS"); - if (const char* cflags = source->GetProperty(COMPILE_FLAGS)) { + if (cmProp cflags = source->GetProperty(COMPILE_FLAGS)) { this->LocalGenerator->AppendFlags( - flags, genexInterpreter.Evaluate(cflags, COMPILE_FLAGS)); + flags, genexInterpreter.Evaluate(*cflags, COMPILE_FLAGS)); } const std::string COMPILE_OPTIONS("COMPILE_OPTIONS"); - if (const char* coptions = source->GetProperty(COMPILE_OPTIONS)) { + if (cmProp coptions = source->GetProperty(COMPILE_OPTIONS)) { this->LocalGenerator->AppendCompileOptions( - flags, genexInterpreter.Evaluate(coptions, COMPILE_OPTIONS)); + flags, genexInterpreter.Evaluate(*coptions, COMPILE_OPTIONS)); } // Add precompile headers compile options. @@ -281,17 +281,17 @@ std::string cmNinjaTargetGenerator::ComputeDefines(cmSourceFile const* source, } const std::string COMPILE_DEFINITIONS("COMPILE_DEFINITIONS"); - if (const char* compile_defs = source->GetProperty(COMPILE_DEFINITIONS)) { + if (cmProp compile_defs = source->GetProperty(COMPILE_DEFINITIONS)) { this->LocalGenerator->AppendDefines( - defines, genexInterpreter.Evaluate(compile_defs, COMPILE_DEFINITIONS)); + defines, genexInterpreter.Evaluate(*compile_defs, COMPILE_DEFINITIONS)); } std::string defPropName = cmStrCat("COMPILE_DEFINITIONS_", cmSystemTools::UpperCase(config)); - if (const char* config_compile_defs = source->GetProperty(defPropName)) { + if (cmProp config_compile_defs = source->GetProperty(defPropName)) { this->LocalGenerator->AppendDefines( defines, - genexInterpreter.Evaluate(config_compile_defs, COMPILE_DEFINITIONS)); + genexInterpreter.Evaluate(*config_compile_defs, COMPILE_DEFINITIONS)); } std::string definesString = this->GetDefines(language, config); @@ -309,9 +309,9 @@ std::string cmNinjaTargetGenerator::ComputeIncludes( this->LocalGenerator, config, this->GeneratorTarget, language); const std::string INCLUDE_DIRECTORIES("INCLUDE_DIRECTORIES"); - if (const char* cincludes = source->GetProperty(INCLUDE_DIRECTORIES)) { + if (cmProp cincludes = source->GetProperty(INCLUDE_DIRECTORIES)) { this->LocalGenerator->AppendIncludeDirectories( - includes, genexInterpreter.Evaluate(cincludes, INCLUDE_DIRECTORIES), + includes, genexInterpreter.Evaluate(*cincludes, INCLUDE_DIRECTORIES), *source); } @@ -1096,8 +1096,8 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( } } - if (const char* objectDeps = source->GetProperty("OBJECT_DEPENDS")) { - std::vector<std::string> objDepList = cmExpandedList(objectDeps); + if (cmProp objectDeps = source->GetProperty("OBJECT_DEPENDS")) { + std::vector<std::string> objDepList = cmExpandedList(*objectDeps); std::copy(objDepList.begin(), objDepList.end(), std::back_inserter(depList)); } @@ -1264,10 +1264,10 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( objBuild, commandLineLengthLimit); } - if (const char* objectOutputs = source->GetProperty("OBJECT_OUTPUTS")) { + if (cmProp objectOutputs = source->GetProperty("OBJECT_OUTPUTS")) { cmNinjaBuild build("phony"); build.Comment = "Additional output files."; - build.Outputs = cmExpandedList(objectOutputs); + build.Outputs = cmExpandedList(*objectOutputs); std::transform(build.Outputs.begin(), build.Outputs.end(), build.Outputs.begin(), MapToNinjaPath()); build.ExplicitDeps = objBuild.Outputs; @@ -1331,14 +1331,14 @@ void cmNinjaTargetGenerator::EmitSwiftDependencyInfo( std::string const objectFilePath = this->ConvertToNinjaPath(this->GetObjectFilePath(source, config)); std::string const swiftDepsPath = [source, objectFilePath]() -> std::string { - if (const char* name = source->GetProperty("Swift_DEPENDENCIES_FILE")) { - return name; + if (cmProp name = source->GetProperty("Swift_DEPENDENCIES_FILE")) { + return *name; } return cmStrCat(objectFilePath, ".swiftdeps"); }(); std::string const swiftDiaPath = [source, objectFilePath]() -> std::string { - if (const char* name = source->GetProperty("Swift_DIAGNOSTICS_FILE")) { - return name; + if (cmProp name = source->GetProperty("Swift_DIAGNOSTICS_FILE")) { + return *name; } return cmStrCat(objectFilePath, ".dia"); }(); diff --git a/Source/cmQTWrapCPPCommand.cxx b/Source/cmQTWrapCPPCommand.cxx index cc4df8f..48c4b10 100644 --- a/Source/cmQTWrapCPPCommand.cxx +++ b/Source/cmQTWrapCPPCommand.cxx @@ -39,7 +39,8 @@ bool cmQTWrapCPPCommand(std::vector<std::string> const& args, cmStrCat(mf.GetCurrentBinaryDirectory(), "/moc_", srcName, ".cxx"); cmSourceFile* sf = mf.GetOrCreateSource(newName, true); if (curr) { - sf->SetProperty("ABSTRACT", curr->GetProperty("ABSTRACT")); + cmProp p = curr->GetProperty("ABSTRACT"); + sf->SetProperty("ABSTRACT", p ? p->c_str() : nullptr); } // Compute the name of the header from which to generate the file. diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index a5af810..87f4656 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -1097,6 +1097,7 @@ bool cmQtAutoGenInitializer::InitAutogenTarget() // of fiddling with the include directories std::vector<std::string> configs; this->GlobalGen->GetQtAutoGenConfigs(configs); + bool stdPipesUTF8 = true; cmCustomCommandLines commandLines; for (auto const& config : configs) { commandLines.push_back(cmMakeCommandLine( @@ -1141,7 +1142,7 @@ bool cmQtAutoGenInitializer::InitAutogenTarget() const std::vector<std::string> no_deps; cmCustomCommand cc(no_output, autogenProvides, no_deps, commandLines, this->Makefile->GetBacktrace(), autogenComment.c_str(), - this->Dir.Work.c_str()); + this->Dir.Work.c_str(), stdPipesUTF8); cc.SetEscapeOldStyle(false); cc.SetEscapeAllowMakeVars(true); this->GenTarget->Target->AddPreBuildCommand(std::move(cc)); @@ -1211,7 +1212,8 @@ bool cmQtAutoGenInitializer::InitAutogenTarget() autogenComment.c_str(), this->Dir.Work.c_str(), /*replace=*/false, /*escapeOldStyle=*/false, /*uses_terminal=*/false, - /*command_expand_lists=*/false, this->AutogenTarget.DepFile); + /*command_expand_lists=*/false, this->AutogenTarget.DepFile, "", + stdPipesUTF8); // Alter variables for the autogen target which now merely wraps the // custom command @@ -1282,6 +1284,7 @@ bool cmQtAutoGenInitializer::InitRccTargets() ccDepends.push_back(qrc.QrcFile); ccDepends.push_back(qrc.InfoFile); + bool stdPipesUTF8 = true; cmCustomCommandLines commandLines; if (this->MultiConfig) { // Build for all configurations @@ -1310,7 +1313,8 @@ bool cmQtAutoGenInitializer::InitRccTargets() cmTarget* autoRccTarget = this->LocalGen->AddUtilityCommand( ccName, true, this->Dir.Work.c_str(), ccOutput, ccDepends, - commandLines, false, ccComment.c_str()); + commandLines, false, ccComment.c_str(), false, false, "", + stdPipesUTF8); // Create autogen generator target this->LocalGen->AddGeneratorTarget( @@ -1350,7 +1354,8 @@ bool cmQtAutoGenInitializer::InitRccTargets() this->LocalGen->AddCustomCommandToOutput( ccOutput, ccByproducts, ccDepends, no_main_dependency, no_implicit_depends, commandLines, ccComment.c_str(), - this->Dir.Work.c_str()); + this->Dir.Work.c_str(), false, true, false, false, "", "", + stdPipesUTF8); } // Reconfigure when .qrc file changes this->Makefile->AddCMakeDependFile(qrc.QrcFile); diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index ad59cd6..f525439 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -48,9 +48,9 @@ std::string cmSourceFile::GetObjectLibrary() const std::string const& cmSourceFile::GetOrDetermineLanguage() { // If the language was set explicitly by the user then use it. - if (const char* lang = this->GetProperty(propLANGUAGE)) { + if (cmProp lang = this->GetProperty(propLANGUAGE)) { // Assign to member in order to return a reference. - this->Language = lang; + this->Language = *lang; return this->Language; } @@ -81,8 +81,8 @@ std::string const& cmSourceFile::GetOrDetermineLanguage() std::string cmSourceFile::GetLanguage() const { // If the language was set explicitly by the user then use it. - if (const char* lang = this->GetProperty(propLANGUAGE)) { - return lang; + if (cmProp lang = this->GetProperty(propLANGUAGE)) { + return *lang; } // Use the language determined from the file extension. @@ -317,17 +317,18 @@ const char* cmSourceFile::GetPropertyForUser(const std::string& prop) } // Perform the normal property lookup. - return this->GetProperty(prop); + cmProp p = this->GetProperty(prop); + return p ? p->c_str() : nullptr; } -const char* cmSourceFile::GetProperty(const std::string& prop) const +cmProp cmSourceFile::GetProperty(const std::string& prop) const { // Check for computed properties. if (prop == propLOCATION) { if (this->FullPath.empty()) { return nullptr; } - return this->FullPath.c_str(); + return &this->FullPath; } // Check for the properties with backtraces. @@ -338,7 +339,7 @@ const char* cmSourceFile::GetProperty(const std::string& prop) const static std::string output; output = cmJoin(this->IncludeDirectories, ";"); - return output.c_str(); + return &output; } if (prop == propCOMPILE_OPTIONS) { @@ -348,7 +349,7 @@ const char* cmSourceFile::GetProperty(const std::string& prop) const static std::string output; output = cmJoin(this->CompileOptions, ";"); - return output.c_str(); + return &output; } if (prop == propCOMPILE_DEFINITIONS) { @@ -358,7 +359,7 @@ const char* cmSourceFile::GetProperty(const std::string& prop) const static std::string output; output = cmJoin(this->CompileDefinitions, ";"); - return output.c_str(); + return &output; } cmProp retVal = this->Properties.GetPropertyValue(prop); @@ -367,28 +368,27 @@ const char* cmSourceFile::GetProperty(const std::string& prop) const const bool chain = mf->GetState()->IsPropertyChained(prop, cmProperty::SOURCE_FILE); if (chain) { - if (cmProp p = mf->GetProperty(prop, chain)) { - return p->c_str(); - } + return mf->GetProperty(prop, chain); } return nullptr; } - return retVal->c_str(); + return retVal; } const char* cmSourceFile::GetSafeProperty(const std::string& prop) const { - const char* ret = this->GetProperty(prop); + cmProp ret = this->GetProperty(prop); if (!ret) { return ""; } - return ret; + return ret->c_str(); } bool cmSourceFile::GetPropertyAsBool(const std::string& prop) const { - return cmIsOn(this->GetProperty(prop)); + cmProp p = this->GetProperty(prop); + return p && cmIsOn(*p); } void cmSourceFile::SetProperties(cmPropertyMap properties) diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h index e22829f..e527069 100644 --- a/Source/cmSourceFile.h +++ b/Source/cmSourceFile.h @@ -17,6 +17,8 @@ class cmMakefile; +using cmProp = const std::string*; + /** \class cmSourceFile * \brief Represent a class loaded from a makefile. * @@ -45,7 +47,7 @@ public: void AppendProperty(const std::string& prop, const std::string& value, bool asString = false); //! Might return a nullptr if the property is not set or invalid - const char* GetProperty(const std::string& prop) const; + cmProp GetProperty(const std::string& prop) const; //! Always returns a valid pointer const char* GetSafeProperty(const std::string& prop) const; bool GetPropertyAsBool(const std::string& prop) const; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 063576c..0c4311d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -238,8 +238,11 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, !impl->Makefile->GetSafeDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX").empty(); // Check whether we are targeting AIX. - impl->IsAIX = - (impl->Makefile->GetSafeDefinition("CMAKE_SYSTEM_NAME") == "AIX"); + { + std::string const& systemName = + impl->Makefile->GetSafeDefinition("CMAKE_SYSTEM_NAME"); + impl->IsAIX = (systemName == "AIX" || systemName == "OS400"); + } // Check whether we are targeting an Android platform. impl->IsAndroid = diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index ec7fe96..6cd8edd 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -983,8 +983,8 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup(Elem& e0) ".Designer.cs"; if (cmsys::SystemTools::FileExists(designerResource)) { std::string generator = "PublicResXFileCodeGenerator"; - if (const char* g = oi->GetProperty("VS_RESOURCE_GENERATOR")) { - generator = g; + if (cmProp g = oi->GetProperty("VS_RESOURCE_GENERATOR")) { + generator = *g; } if (!generator.empty()) { e2.Element("Generator", generator); @@ -1027,10 +1027,10 @@ void cmVisualStudio10TargetGenerator::WriteXamlFilesGroup(Elem& e0) Elem e1(e0, "ItemGroup"); for (cmSourceFile const* oi : xamlObjs) { std::string obj = oi->GetFullPath(); - const char* xamlType; - const char* xamlTypeProperty = oi->GetProperty("VS_XAML_TYPE"); + std::string xamlType; + cmProp xamlTypeProperty = oi->GetProperty("VS_XAML_TYPE"); if (xamlTypeProperty) { - xamlType = xamlTypeProperty; + xamlType = *xamlTypeProperty; } else { xamlType = "Page"; } @@ -1404,6 +1404,9 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule( spe2 = cm::make_unique<Elem>(*spe1, "CustomBuild"); this->WriteSource(*spe2, source); spe2->SetHasElements(); + if (command.GetStdPipesUTF8()) { + this->WriteStdOutEncodingUtf8(*spe2); + } } else { Elem e1(e0, "ItemGroup"); Elem e2(e1, "None"); @@ -1745,9 +1748,9 @@ void cmVisualStudio10TargetGenerator::WriteHeaderSource(Elem& e1, } void cmVisualStudio10TargetGenerator::ParseSettingsProperty( - const char* settingsPropertyValue, ConfigToSettings& toolSettings) + const std::string& settingsPropertyValue, ConfigToSettings& toolSettings) { - if (settingsPropertyValue) { + if (!settingsPropertyValue.empty()) { cmGeneratorExpression ge; std::unique_ptr<cmCompiledGeneratorExpression> cge = @@ -1821,45 +1824,45 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1, if (ext == "hlsl") { tool = "FXCompile"; // Figure out the type of shader compiler to use. - if (const char* st = sf->GetProperty("VS_SHADER_TYPE")) { + if (cmProp st = sf->GetProperty("VS_SHADER_TYPE")) { for (const std::string& config : this->Configurations) { - toolSettings[config]["ShaderType"] = st; + toolSettings[config]["ShaderType"] = *st; } } // Figure out which entry point to use if any - if (const char* se = sf->GetProperty("VS_SHADER_ENTRYPOINT")) { + if (cmProp se = sf->GetProperty("VS_SHADER_ENTRYPOINT")) { for (const std::string& config : this->Configurations) { - toolSettings[config]["EntryPointName"] = se; + toolSettings[config]["EntryPointName"] = *se; } } // Figure out which shader model to use if any - if (const char* sm = sf->GetProperty("VS_SHADER_MODEL")) { + if (cmProp sm = sf->GetProperty("VS_SHADER_MODEL")) { for (const std::string& config : this->Configurations) { - toolSettings[config]["ShaderModel"] = sm; + toolSettings[config]["ShaderModel"] = *sm; } } // Figure out which output header file to use if any - if (const char* ohf = sf->GetProperty("VS_SHADER_OUTPUT_HEADER_FILE")) { + if (cmProp ohf = sf->GetProperty("VS_SHADER_OUTPUT_HEADER_FILE")) { for (const std::string& config : this->Configurations) { - toolSettings[config]["HeaderFileOutput"] = ohf; + toolSettings[config]["HeaderFileOutput"] = *ohf; } } // Figure out which variable name to use if any - if (const char* vn = sf->GetProperty("VS_SHADER_VARIABLE_NAME")) { + if (cmProp vn = sf->GetProperty("VS_SHADER_VARIABLE_NAME")) { for (const std::string& config : this->Configurations) { - toolSettings[config]["VariableName"] = vn; + toolSettings[config]["VariableName"] = *vn; } } // Figure out if there's any additional flags to use - if (const char* saf = sf->GetProperty("VS_SHADER_FLAGS")) { + if (cmProp saf = sf->GetProperty("VS_SHADER_FLAGS")) { for (const std::string& config : this->Configurations) { - toolSettings[config]["AdditionalOptions"] = saf; + toolSettings[config]["AdditionalOptions"] = *saf; } } // Figure out if debug information should be generated - if (const char* sed = sf->GetProperty("VS_SHADER_ENABLE_DEBUG")) { + if (cmProp sed = sf->GetProperty("VS_SHADER_ENABLE_DEBUG")) { cmGeneratorExpression ge; - std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(sed); + std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(*sed); for (const std::string& config : this->Configurations) { std::string evaluated = cge->Evaluate(this->LocalGenerator, config); @@ -1871,9 +1874,9 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1, } } // Figure out if optimizations should be disabled - if (const char* sdo = sf->GetProperty("VS_SHADER_DISABLE_OPTIMIZATIONS")) { + if (cmProp sdo = sf->GetProperty("VS_SHADER_DISABLE_OPTIMIZATIONS")) { cmGeneratorExpression ge; - std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(sdo); + std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(*sdo); for (const std::string& config : this->Configurations) { std::string evaluated = cge->Evaluate(this->LocalGenerator, config); @@ -1884,9 +1887,9 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1, } } } - if (const char* sofn = sf->GetProperty("VS_SHADER_OBJECT_FILE_NAME")) { + if (cmProp sofn = sf->GetProperty("VS_SHADER_OBJECT_FILE_NAME")) { for (const std::string& config : this->Configurations) { - toolSettings[config]["ObjectFileOutput"] = sofn; + toolSettings[config]["ObjectFileOutput"] = *sofn; } } } else if (ext == "jpg" || ext == "png") { @@ -1907,9 +1910,9 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1, } else if (ext == "vsixmanifest") { subType = "Designer"; } - if (const char* c = sf->GetProperty("VS_COPY_TO_OUT_DIR")) { + if (cmProp c = sf->GetProperty("VS_COPY_TO_OUT_DIR")) { tool = "Content"; - copyToOutDir = c; + copyToOutDir = *c; toolHasSettings = true; } if (sf->GetPropertyAsBool("VS_INCLUDE_IN_VSIX")) { @@ -1936,23 +1939,23 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1, } } - const char* toolOverride = sf->GetProperty("VS_TOOL_OVERRIDE"); - if (toolOverride && *toolOverride) { - tool = toolOverride; + cmProp toolOverride = sf->GetProperty("VS_TOOL_OVERRIDE"); + if (toolOverride && !toolOverride->empty()) { + tool = toolOverride->c_str(); } std::string deployContent; std::string deployLocation; if (this->GlobalGenerator->TargetsWindowsPhone() || this->GlobalGenerator->TargetsWindowsStore()) { - const char* content = sf->GetProperty("VS_DEPLOYMENT_CONTENT"); - if (content && *content) { + cmProp content = sf->GetProperty("VS_DEPLOYMENT_CONTENT"); + if (content && !content->empty()) { toolHasSettings = true; - deployContent = content; + deployContent = *content; - const char* location = sf->GetProperty("VS_DEPLOYMENT_LOCATION"); - if (location && *location) { - deployLocation = location; + cmProp location = sf->GetProperty("VS_DEPLOYMENT_LOCATION"); + if (location && !location->empty()) { + deployLocation = *location; } } } @@ -1962,7 +1965,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1, "VS_SOURCE_SETTINGS_" + std::string(tool)); ConfigToSettings toolTargetSettings; if (toolTargetProperty) { - ParseSettingsProperty(toolTargetProperty->c_str(), toolTargetSettings); + ParseSettingsProperty(*toolTargetProperty, toolTargetSettings); } ParsedToolTargetSettings[tool] = toolTargetSettings; @@ -1974,7 +1977,9 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1, } } - ParseSettingsProperty(sf->GetProperty("VS_SETTINGS"), toolSettings); + if (cmProp p = sf->GetProperty("VS_SETTINGS")) { + ParseSettingsProperty(*p, toolSettings); + } if (!toolSettings.empty()) { toolHasSettings = true; @@ -2248,7 +2253,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0) e2.Attribute("CustomUnityFile", "true"); std::string unityDir = cmSystemTools::GetFilenamePath( - si.Source->GetProperty("UNITY_SOURCE_FILE")); + *si.Source->GetProperty("UNITY_SOURCE_FILE")); e2.Attribute("UnityFilesDirectory", unityDir); } else { // Visual Studio versions prior to 2017 15.8 do not know about unity @@ -2293,25 +2298,25 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( bool configDependentDefines = false; std::string includes; bool configDependentIncludes = false; - if (const char* cflags = sf.GetProperty("COMPILE_FLAGS")) { + if (cmProp cflags = sf.GetProperty("COMPILE_FLAGS")) { configDependentFlags = - cmGeneratorExpression::Find(cflags) != std::string::npos; - flags += cflags; + cmGeneratorExpression::Find(*cflags) != std::string::npos; + flags += *cflags; } - if (const char* coptions = sf.GetProperty("COMPILE_OPTIONS")) { + if (cmProp coptions = sf.GetProperty("COMPILE_OPTIONS")) { configDependentOptions = - cmGeneratorExpression::Find(coptions) != std::string::npos; - options += coptions; + cmGeneratorExpression::Find(*coptions) != std::string::npos; + options += *coptions; } - if (const char* cdefs = sf.GetProperty("COMPILE_DEFINITIONS")) { + if (cmProp cdefs = sf.GetProperty("COMPILE_DEFINITIONS")) { configDependentDefines = - cmGeneratorExpression::Find(cdefs) != std::string::npos; - defines += cdefs; + cmGeneratorExpression::Find(*cdefs) != std::string::npos; + defines += *cdefs; } - if (const char* cincludes = sf.GetProperty("INCLUDE_DIRECTORIES")) { + if (cmProp cincludes = sf.GetProperty("INCLUDE_DIRECTORIES")) { configDependentIncludes = - cmGeneratorExpression::Find(cincludes) != std::string::npos; - includes += cincludes; + cmGeneratorExpression::Find(*cincludes) != std::string::npos; + includes += *cincludes; } std::string lang = this->GlobalGenerator->GetLanguageFromExtension(sf.GetExtension().c_str()); @@ -2350,13 +2355,13 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( std::string configUpper = cmSystemTools::UpperCase(config); std::string configDefines = defines; std::string defPropName = cmStrCat("COMPILE_DEFINITIONS_", configUpper); - if (const char* ccdefs = sf.GetProperty(defPropName)) { + if (cmProp ccdefs = sf.GetProperty(defPropName)) { if (!configDefines.empty()) { configDefines += ";"; } configDependentDefines |= - cmGeneratorExpression::Find(ccdefs) != std::string::npos; - configDefines += ccdefs; + cmGeneratorExpression::Find(*ccdefs) != std::string::npos; + configDefines += *ccdefs; } // Add precompile headers compile options. @@ -4048,6 +4053,7 @@ void cmVisualStudio10TargetGenerator::WriteEvent( std::string script; const char* pre = ""; std::string comment; + bool stdPipesUTF8 = false; for (cmCustomCommand const& cc : commands) { cmCustomCommandGenerator ccg(cc, configName, lg); if (!ccg.HasOnlyEmptyCommandLines()) { @@ -4056,11 +4062,16 @@ void cmVisualStudio10TargetGenerator::WriteEvent( script += pre; pre = "\n"; script += lg->ConstructScript(ccg); + + stdPipesUTF8 = stdPipesUTF8 || cc.GetStdPipesUTF8(); } } comment = cmVS10EscapeComment(comment); if (this->ProjectType != csproj) { Elem e2(e1, name); + if (stdPipesUTF8) { + this->WriteStdOutEncodingUtf8(e2); + } e2.Element("Message", comment); e2.Element("Command", script); } else { @@ -4887,8 +4898,8 @@ std::string cmVisualStudio10TargetGenerator::GetCSharpSourceLink( link = fullFileName.substr(srcDir.length() + 1); } else if (cmHasPrefix(fullFileName, binDir)) { link = fullFileName.substr(binDir.length() + 1); - } else if (const char* l = source->GetProperty("VS_CSHARP_Link")) { - link = l; + } else if (cmProp l = source->GetProperty("VS_CSHARP_Link")) { + link = *l; } ConvertToWindowsSlash(link); @@ -4905,3 +4916,8 @@ std::string cmVisualStudio10TargetGenerator::GetCMakeFilePath( return path; } + +void cmVisualStudio10TargetGenerator::WriteStdOutEncodingUtf8(Elem& e1) +{ + e1.Element("StdOutEncoding", "UTF-8"); +} diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index e588de8..e3782f4 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -184,6 +184,8 @@ private: Elem& e2, const std::map<std::string, std::string>& tags); std::string GetCSharpSourceLink(cmSourceFile const* source); + void WriteStdOutEncodingUtf8(Elem& e1); + private: friend class cmVS10GeneratorOptions; using Options = cmVS10GeneratorOptions; @@ -242,7 +244,7 @@ private: std::unordered_map<std::string, ConfigToSettings> ParsedToolTargetSettings; bool PropertyIsSameInAllConfigs(const ConfigToSettings& toolSettings, const std::string& propName); - void ParseSettingsProperty(const char* settingsPropertyValue, + void ParseSettingsProperty(const std::string& settingsPropertyValue, ConfigToSettings& toolSettings); std::string GetCMakeFilePath(const char* name) const; }; diff --git a/Tests/CPackNSISGenerator/CMakeLists.txt b/Tests/CPackNSISGenerator/CMakeLists.txt index b8b2ed6..8ed4d59 100644 --- a/Tests/CPackNSISGenerator/CMakeLists.txt +++ b/Tests/CPackNSISGenerator/CMakeLists.txt @@ -16,5 +16,6 @@ set(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}\\\\install.ico") set(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}\\\\uninstall.ico") set(CPACK_GENERATOR "NSIS") set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON) +set(CPACK_NSIS_MANIFEST_DPI_AWARE ON) include(CPack) diff --git a/Tests/CPackNSISGenerator/RunCPackVerifyResult.cmake b/Tests/CPackNSISGenerator/RunCPackVerifyResult.cmake index 01b37c5..bfbcf9c 100644 --- a/Tests/CPackNSISGenerator/RunCPackVerifyResult.cmake +++ b/Tests/CPackNSISGenerator/RunCPackVerifyResult.cmake @@ -44,3 +44,11 @@ message(STATUS "Found the bitmap at index ${output_index}") if("${output_index}" EQUAL "-1") message(FATAL_ERROR "MUI_HEADERIMAGE_BITMAP not found in the project") endif() + +file(STRINGS "${project_file}" line REGEX "^ManifestDPIAware true") +string(FIND "${line}" "true" output_index) +if("${output_index}" EQUAL "-1") + message(FATAL_ERROR "ManifestDPIAware true not found in the project") +else() + message(STATUS "Found DPI-aware") +endif() |