diff options
148 files changed, 4406 insertions, 1061 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ac8e168..6a41406 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1178,6 +1178,36 @@ t:windows-clang16.0-gnu-nmake: CMAKE_CI_BUILD_NAME: windows_clang16.0_gnu_nmake CMAKE_CI_JOB_NIGHTLY: "true" +t:windows-intel2021.9.0-ninja: + extends: + - .windows_intelclassic_ninja + - .cmake_test_windows_external + - .windows_x86_64_tags_concurrent + - .cmake_junit_artifacts + - .run_dependent + dependencies: + - t:windows-vs2022-x64-ninja + needs: + - t:windows-vs2022-x64-ninja + variables: + CMAKE_CI_BUILD_NAME: windows_intel2021.9.0_ninja + CMAKE_CI_JOB_NIGHTLY: "true" + +t:windows-oneapi2023.1.0-ninja: + extends: + - .windows_inteloneapi_ninja + - .cmake_test_windows_external + - .windows_x86_64_tags_concurrent + - .cmake_junit_artifacts + - .run_dependent + dependencies: + - t:windows-vs2022-x64-ninja + needs: + - t:windows-vs2022-x64-ninja + variables: + CMAKE_CI_BUILD_NAME: windows_oneapi2023.1.0_ninja + CMAKE_CI_JOB_NIGHTLY: "true" + t:mingw_osdn_io-mingw_makefiles: extends: - .mingw_osdn_io_mingw_makefiles diff --git a/.gitlab/.gitignore b/.gitlab/.gitignore index 10d03ca..852dfa6 100644 --- a/.gitlab/.gitignore +++ b/.gitlab/.gitignore @@ -2,7 +2,9 @@ /5.15.1-0-202009071110* /bcc* /cmake* +/intel /ispc* +/innosetup /jom /llvm* /mingw diff --git a/.gitlab/ci/configure_windows_intelclassic_ninja.cmake b/.gitlab/ci/configure_windows_intelclassic_ninja.cmake new file mode 100644 index 0000000..c2d708b --- /dev/null +++ b/.gitlab/ci/configure_windows_intelclassic_ninja.cmake @@ -0,0 +1 @@ +include("${CMAKE_CURRENT_LIST_DIR}/configure_windows_intelcompiler_common.cmake") diff --git a/.gitlab/ci/configure_windows_intelcompiler_common.cmake b/.gitlab/ci/configure_windows_intelcompiler_common.cmake new file mode 100644 index 0000000..55dce1d --- /dev/null +++ b/.gitlab/ci/configure_windows_intelcompiler_common.cmake @@ -0,0 +1,5 @@ +set(CMake_TEST_Java OFF CACHE BOOL "") + +set(configure_no_sccache 1) + +include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake") diff --git a/.gitlab/ci/configure_windows_inteloneapi_ninja.cmake b/.gitlab/ci/configure_windows_inteloneapi_ninja.cmake new file mode 100644 index 0000000..c2d708b --- /dev/null +++ b/.gitlab/ci/configure_windows_inteloneapi_ninja.cmake @@ -0,0 +1 @@ +include("${CMAKE_CURRENT_LIST_DIR}/configure_windows_intelcompiler_common.cmake") diff --git a/.gitlab/ci/configure_windows_vs2022_x64_ninja.cmake b/.gitlab/ci/configure_windows_vs2022_x64_ninja.cmake index 5bf0be8..54abf72 100644 --- a/.gitlab/ci/configure_windows_vs2022_x64_ninja.cmake +++ b/.gitlab/ci/configure_windows_vs2022_x64_ninja.cmake @@ -1,4 +1,5 @@ if (NOT "$ENV{CMAKE_CI_NIGHTLY}" STREQUAL "") + set(CMake_TEST_CPACK_INNOSETUP "ON" CACHE STRING "") set(CMake_TEST_ISPC "ON" CACHE STRING "") endif() set(CMake_TEST_TLS_VERIFY_URL "https://gitlab.kitware.com" CACHE STRING "") diff --git a/.gitlab/ci/env_windows_intelclassic_ninja.ps1 b/.gitlab/ci/env_windows_intelclassic_ninja.ps1 new file mode 100755 index 0000000..99f83b9 --- /dev/null +++ b/.gitlab/ci/env_windows_intelclassic_ninja.ps1 @@ -0,0 +1,9 @@ +. .gitlab/ci/ninja-env.ps1 +. .gitlab/ci/intel-env.ps1 + +$env:CC = "icl" +$env:CXX = "icl" +$env:FC = "ifort" + +cmd /c "icl 2>&1" | Select -First 1 +cmd /c "ifort 2>&1" | Select -First 1 diff --git a/.gitlab/ci/env_windows_inteloneapi_ninja.ps1 b/.gitlab/ci/env_windows_inteloneapi_ninja.ps1 new file mode 100755 index 0000000..3bd1d46 --- /dev/null +++ b/.gitlab/ci/env_windows_inteloneapi_ninja.ps1 @@ -0,0 +1,9 @@ +. .gitlab/ci/ninja-env.ps1 +. .gitlab/ci/intel-env.ps1 + +$env:CC = "icx" +$env:CXX = "icx" +$env:FC = "ifx" + +cmd /c "icx 2>&1" | Select -First 1 +cmd /c "ifx 2>&1" | Select -First 1 diff --git a/.gitlab/ci/env_windows_vs2022_x64_ninja.ps1 b/.gitlab/ci/env_windows_vs2022_x64_ninja.ps1 index a96658d..50a03ca 100755 --- a/.gitlab/ci/env_windows_vs2022_x64_ninja.ps1 +++ b/.gitlab/ci/env_windows_vs2022_x64_ninja.ps1 @@ -1,3 +1,4 @@ if ("$env:CMAKE_CI_NIGHTLY" -eq "true") { + . ".gitlab/ci/innosetup-env.ps1" . ".gitlab/ci/ispc-env.ps1" } diff --git a/.gitlab/ci/innosetup-env.ps1 b/.gitlab/ci/innosetup-env.ps1 new file mode 100755 index 0000000..96e9d8c --- /dev/null +++ b/.gitlab/ci/innosetup-env.ps1 @@ -0,0 +1,4 @@ +$pwdpath = $pwd.Path +& "$pwsh" -File ".gitlab/ci/innosetup.ps1" +Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab\innosetup;$env:PATH" +ISCC 2>$null | Select -First 1 diff --git a/.gitlab/ci/innosetup.ps1 b/.gitlab/ci/innosetup.ps1 new file mode 100755 index 0000000..a7f4eb3 --- /dev/null +++ b/.gitlab/ci/innosetup.ps1 @@ -0,0 +1,20 @@ +$erroractionpreference = "stop" + +$version = "6.2.2-1" +$sha256sum = "34D5311070678617424628A88C8A7F7BE41157B1A59112F9DFDA1D7EFD4469CC" +$filename = "innosetup-$version" +$tarball = "$filename.zip" + +$outdir = $pwd.Path +$outdir = "$outdir\.gitlab" +$ProgressPreference = 'SilentlyContinue' +Invoke-WebRequest -Uri "https://cmake.org/files/dependencies/internal/$tarball" -OutFile "$outdir\$tarball" +$hash = Get-FileHash "$outdir\$tarball" -Algorithm SHA256 +if ($hash.Hash -ne $sha256sum) { + exit 1 +} + +Add-Type -AssemblyName System.IO.Compression.FileSystem +[System.IO.Compression.ZipFile]::ExtractToDirectory("$outdir\$tarball", "$outdir") +Move-Item -Path "$outdir\$filename" -Destination "$outdir\innosetup" +Remove-Item "$outdir\$tarball" diff --git a/.gitlab/ci/intel-env.ps1 b/.gitlab/ci/intel-env.ps1 new file mode 100755 index 0000000..75f7286 --- /dev/null +++ b/.gitlab/ci/intel-env.ps1 @@ -0,0 +1,4 @@ +$pwdpath = $pwd.Path +& "$pwsh" -File ".gitlab/ci/intel.ps1" +Invoke-Expression -Command .gitlab/ci/vcvarsall.ps1 +Invoke-Expression -Command .gitlab/ci/intel-vars.ps1 diff --git a/.gitlab/ci/intel-vars.ps1 b/.gitlab/ci/intel-vars.ps1 new file mode 100755 index 0000000..dde0aa2 --- /dev/null +++ b/.gitlab/ci/intel-vars.ps1 @@ -0,0 +1,9 @@ +$erroractionpreference = "stop" + +cmd /c "`".gitlab\intel\setvars.bat`" & set" | +foreach { + if ($_ -match "=") { + $v = $_.split("=") + [Environment]::SetEnvironmentVariable($v[0], $v[1]) + } +} diff --git a/.gitlab/ci/intel.ps1 b/.gitlab/ci/intel.ps1 new file mode 100755 index 0000000..2262669 --- /dev/null +++ b/.gitlab/ci/intel.ps1 @@ -0,0 +1,42 @@ +$erroractionpreference = "stop" + +if ("$env:CMAKE_CI_BUILD_NAME" -match "(^|_)(oneapi2023\.1\.0|intel2021\.9\.0)(_|$)") { + # Intel oneAPI 2023.1.0 + $version = "2023.1.0" + $filename = "intel-oneapi-$version-windows-1" + $sha256sum = "5AFCA9E0B03894565209B1295476163ABEBB1F1388E0F3EF5B4D0F9189E65BDC" +} else { + throw ('unknown CMAKE_CI_BUILD_NAME: ' + "$env:CMAKE_CI_BUILD_NAME") +} +$tarball = "$filename.zip" + +$outdir = $pwd.Path +$outdir = "$outdir\.gitlab" +$ProgressPreference = 'SilentlyContinue' +# This URL is only visible inside of Kitware's network. See above filename table. +Invoke-WebRequest -Uri "https://cmake.org/files/dependencies/internal/$tarball" -OutFile "$outdir\$tarball" +$hash = Get-FileHash "$outdir\$tarball" -Algorithm SHA256 +if ($hash.Hash -ne $sha256sum) { + exit 1 +} + +Add-Type -AssemblyName System.IO.Compression.FileSystem +[System.IO.Compression.ZipFile]::ExtractToDirectory("$outdir\$tarball", "$outdir") +Move-Item -Path "$outdir\$filename" -Destination "$outdir\intel" +Remove-Item "$outdir\$tarball" + +$compiler = "$outdir\intel\compiler" +$bin = "$compiler\$version\windows\bin" +$null = New-Item -ItemType Junction -Path "$compiler\latest" -Target "$compiler\$version" +$null = New-Item -ItemType HardLink -Path "$bin\icx-cl.exe" -Target "$bin\icx.exe" +$null = New-Item -ItemType HardLink -Path "$bin\icx-cc.exe" -Target "$bin\icx.exe" +$null = New-Item -ItemType HardLink -Path "$bin\icpx.exe" -Target "$bin\icx.exe" +$bin = "$compiler\$version\windows\bin-llvm" +$null = New-Item -ItemType HardLink -Path "$bin\clang-cl.exe" -Target "$bin\clang.exe" +$null = New-Item -ItemType HardLink -Path "$bin\clang-cpp.exe" -Target "$bin\clang.exe" +$null = New-Item -ItemType HardLink -Path "$bin\clang++.exe" -Target "$bin\clang.exe" +$null = New-Item -ItemType HardLink -Path "$bin\lld-link.exe" -Target "$bin\lld.exe" +$null = New-Item -ItemType HardLink -Path "$bin\ld.lld.exe" -Target "$bin\lld.exe" +$null = New-Item -ItemType HardLink -Path "$bin\llvm-lib.exe" -Target "$bin\llvm-ar.exe" +Clear-Variable -Name bin +Clear-Variable -Name compiler diff --git a/.gitlab/os-windows.yml b/.gitlab/os-windows.yml index f1e86ad..07a479e 100644 --- a/.gitlab/os-windows.yml +++ b/.gitlab/os-windows.yml @@ -222,6 +222,22 @@ variables: CMAKE_CONFIGURATION: windows_msvc_v71_nmake +.windows_intelclassic_ninja: + extends: + - .windows_ninja + - .windows_vcvarsall_vs2022_x64 + + variables: + CMAKE_CONFIGURATION: windows_intelclassic_ninja + +.windows_inteloneapi_ninja: + extends: + - .windows_ninja + - .windows_vcvarsall_vs2022_x64 + + variables: + CMAKE_CONFIGURATION: windows_inteloneapi_ninja + .windows_openwatcom: extends: .windows diff --git a/Auxiliary/vim/syntax/cmake.vim b/Auxiliary/vim/syntax/cmake.vim index 814c45a..aefdcee 100644 --- a/Auxiliary/vim/syntax/cmake.vim +++ b/Auxiliary/vim/syntax/cmake.vim @@ -2746,6 +2746,7 @@ syn keyword cmakeKWfile contained \ READ_SYMLINK \ REAL_PATH \ REGEX + \ RELATIVE \ RELATIVE_PATH \ RELEASE \ REMOVE diff --git a/Help/command/FIND_XXX.txt b/Help/command/FIND_XXX.txt index 21236fa..fe26d2b 100644 --- a/Help/command/FIND_XXX.txt +++ b/Help/command/FIND_XXX.txt @@ -132,6 +132,9 @@ If ``NO_DEFAULT_PATH`` is not specified, the search process is as follows: .. |CMAKE_PREFIX_PATH_XXX_SUBDIR| replace:: |prefix_XXX_SUBDIR| for each ``<prefix>`` in :variable:`CMAKE_PREFIX_PATH` +.. |ENV_CMAKE_PREFIX_PATH_XXX_SUBDIR| replace:: + |prefix_XXX_SUBDIR| for each ``<prefix>`` in :envvar:`CMAKE_PREFIX_PATH` + .. |SYSTEM_ENVIRONMENT_PREFIX_PATH_XXX_SUBDIR| replace:: |prefix_XXX_SUBDIR| for each ``<prefix>/[s]bin`` in ``PATH``, and |entry_XXX_SUBDIR| for other entries in ``PATH`` @@ -194,9 +197,9 @@ If ``NO_DEFAULT_PATH`` is not specified, the search process is as follows: This can be skipped if ``NO_CMAKE_ENVIRONMENT_PATH`` is passed or by setting the :variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH` to ``FALSE``. - * |CMAKE_PREFIX_PATH_XXX| - * |CMAKE_XXX_PATH| - * |CMAKE_XXX_MAC_PATH| + * |ENV_CMAKE_PREFIX_PATH_XXX| + * |ENV_CMAKE_XXX_PATH| + * |ENV_CMAKE_XXX_MAC_PATH| 4. Search the paths specified by the ``HINTS`` option. These should be paths computed by system introspection, such as a diff --git a/Help/command/find_file.rst b/Help/command/find_file.rst index c5c4014..9f89f52 100644 --- a/Help/command/find_file.rst +++ b/Help/command/find_file.rst @@ -19,6 +19,13 @@ find_file .. |CMAKE_XXX_PATH| replace:: :variable:`CMAKE_INCLUDE_PATH` .. |CMAKE_XXX_MAC_PATH| replace:: :variable:`CMAKE_FRAMEWORK_PATH` +.. |ENV_CMAKE_PREFIX_PATH_XXX| replace:: + ``<prefix>/include/<arch>`` if :variable:`CMAKE_LIBRARY_ARCHITECTURE` is set, + and |ENV_CMAKE_PREFIX_PATH_XXX_SUBDIR| +.. |ENV_CMAKE_XXX_PATH| replace:: :envvar:`CMAKE_INCLUDE_PATH` +.. |ENV_CMAKE_XXX_MAC_PATH| replace:: :envvar:`CMAKE_FRAMEWORK_PATH` + + .. |SYSTEM_ENVIRONMENT_PATH_XXX| replace:: The directories in ``INCLUDE`` and ``PATH``. .. |SYSTEM_ENVIRONMENT_PATH_WINDOWS_XXX| replace:: On Windows hosts: diff --git a/Help/command/find_library.rst b/Help/command/find_library.rst index c237e7f..99e36a4 100644 --- a/Help/command/find_library.rst +++ b/Help/command/find_library.rst @@ -19,6 +19,12 @@ find_library .. |CMAKE_XXX_PATH| replace:: :variable:`CMAKE_LIBRARY_PATH` .. |CMAKE_XXX_MAC_PATH| replace:: :variable:`CMAKE_FRAMEWORK_PATH` +.. |ENV_CMAKE_PREFIX_PATH_XXX| replace:: + ``<prefix>/lib/<arch>`` if :variable:`CMAKE_LIBRARY_ARCHITECTURE` is set, + and |ENV_CMAKE_PREFIX_PATH_XXX_SUBDIR| +.. |ENV_CMAKE_XXX_PATH| replace:: :envvar:`CMAKE_LIBRARY_PATH` +.. |ENV_CMAKE_XXX_MAC_PATH| replace:: :envvar:`CMAKE_FRAMEWORK_PATH` + .. |SYSTEM_ENVIRONMENT_PATH_XXX| replace:: The directories in ``LIB`` and ``PATH``. .. |SYSTEM_ENVIRONMENT_PATH_WINDOWS_XXX| replace:: On Windows hosts: diff --git a/Help/command/find_package.rst b/Help/command/find_package.rst index b82088e..b0b6fe1 100644 --- a/Help/command/find_package.rst +++ b/Help/command/find_package.rst @@ -418,8 +418,8 @@ enabled. * ``<PackageName>_DIR`` * :envvar:`CMAKE_PREFIX_PATH` - * ``CMAKE_FRAMEWORK_PATH`` - * ``CMAKE_APPBUNDLE_PATH`` + * :envvar:`CMAKE_FRAMEWORK_PATH` + * :envvar:`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/command/find_path.rst b/Help/command/find_path.rst index 1d7648d..f0522f6 100644 --- a/Help/command/find_path.rst +++ b/Help/command/find_path.rst @@ -19,6 +19,12 @@ find_path .. |CMAKE_XXX_PATH| replace:: :variable:`CMAKE_INCLUDE_PATH` .. |CMAKE_XXX_MAC_PATH| replace:: :variable:`CMAKE_FRAMEWORK_PATH` +.. |ENV_CMAKE_PREFIX_PATH_XXX| replace:: + ``<prefix>/include/<arch>`` if :variable:`CMAKE_LIBRARY_ARCHITECTURE` is set, + and |ENV_CMAKE_PREFIX_PATH_XXX_SUBDIR| +.. |ENV_CMAKE_XXX_PATH| replace:: :envvar:`CMAKE_INCLUDE_PATH` +.. |ENV_CMAKE_XXX_MAC_PATH| replace:: :envvar:`CMAKE_FRAMEWORK_PATH` + .. |SYSTEM_ENVIRONMENT_PATH_XXX| replace:: The directories in ``INCLUDE`` and ``PATH``. .. |SYSTEM_ENVIRONMENT_PATH_WINDOWS_XXX| replace:: On Windows hosts: diff --git a/Help/command/find_program.rst b/Help/command/find_program.rst index f4149be..fe95a9a 100644 --- a/Help/command/find_program.rst +++ b/Help/command/find_program.rst @@ -17,6 +17,11 @@ find_program .. |CMAKE_XXX_PATH| replace:: :variable:`CMAKE_PROGRAM_PATH` .. |CMAKE_XXX_MAC_PATH| replace:: :variable:`CMAKE_APPBUNDLE_PATH` +.. |ENV_CMAKE_PREFIX_PATH_XXX| replace:: + |ENV_CMAKE_PREFIX_PATH_XXX_SUBDIR| +.. |ENV_CMAKE_XXX_PATH| replace:: :envvar:`CMAKE_PROGRAM_PATH` +.. |ENV_CMAKE_XXX_MAC_PATH| replace:: :envvar:`CMAKE_APPBUNDLE_PATH` + .. |SYSTEM_ENVIRONMENT_PATH_XXX| replace:: The directories in ``PATH`` itself. .. |SYSTEM_ENVIRONMENT_PATH_WINDOWS_XXX| replace:: On Windows hosts no extra search paths are included diff --git a/Help/cpack_gen/innosetup.rst b/Help/cpack_gen/innosetup.rst new file mode 100644 index 0000000..f48e7f5 --- /dev/null +++ b/Help/cpack_gen/innosetup.rst @@ -0,0 +1,420 @@ +CPack Inno Setup Generator +-------------------------- + +.. versionadded:: 3.27 + +Inno Setup is a free installer for Windows programs by Jordan Russell and +Martijn Laan (https://jrsoftware.org/isinfo.php). + +This documentation explains Inno Setup generator specific options. + +The generator provides a lot of options like components. Unfortunately, not +all features (e.g. component dependencies) are currently supported by +Inno Setup and they're ignored by the generator for now. + +CPack requires Inno Setup 6 or greater and only works on Windows. + +Variables specific to CPack Inno Setup generator +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +You can use the following variables to change the behavior of the CPack +``INNOSETUP`` generator: + + +General +""""""" + +None of the following variables is required to be set for the Inno Setup +generator to work. If a variable is marked as mandatory below but not set, +its default value is taken. + +The variables can also contain Inno Setup constants like ``{app}``. Please +refer to the documentation of Inno Setup for more information. + +If you're asked to provide the path to any file, you can always give an +absolute path or in most cases the relative path from the top-level directory +where all files being installed by an :command:`install` instruction reside. + +CPack tries to escape quotes and other special characters for you. However, +using special characters could cause problems. + +The following variable simplifies the usage of Inno Setup in CMake: + +.. variable:: CPACK_INNOSETUP_USE_CMAKE_BOOL_FORMAT + + Inno Setup only uses ``yes`` or ``no`` as boolean formats meanwhile CMake + uses a lot of alternative formats like ``ON`` or ``OFF``. Having this option + turned on enables an automatic conversion. + + Consider the following example: + + .. code-block:: cmake + + set(CMAKE_INNOSETUP_SETUP_AllowNoIcons OFF) + + If this option is turned on, the following line will be created in the output + script: ``AllowNoIcons=no``. + Else, the following erroneous line will be created: ``AllowNoIcons=OFF`` + + The conversion is enabled in every Inno Setup specific variable. + + :Mandatory: Yes + :Default: ``ON`` + + +Setup Specific Variables +"""""""""""""""""""""""" + +.. variable:: CPACK_INNOSETUP_ARCHITECTURE + + One of ``x86``, ``x64``, ``arm64`` or ``ia64``. This variable specifies the + target architecture of the installer. This also affects the Program Files + folder or registry keys being used. + + CPack tries to determine the correct value with a try compile (see + :variable:`CMAKE_SIZEOF_VOID_P`), but this option can be manually specified + too (especially when using ``ia64`` or cross-platform compilation). + + :Mandatory: Yes + :Default: Either ``x86`` or ``x64`` depending on the results of the try-compile + +.. variable:: CPACK_INNOSETUP_INSTALL_ROOT + + If you don't want the installer to create the installation directory under + Program Files, you've to specify the installation root here. + + The full directory of the installation will be: + ``${CPACK_INNOSETUP_INSTALL_ROOT}/${CPACK_PACKAGE_INSTALL_DIRECTORY}``. + + :Mandatory: Yes + :Default: ``{autopf}`` + +.. variable:: CPACK_INNOSETUP_ALLOW_CUSTOM_DIRECTORY + + If turned on, the installer allows the user to change the installation + directory providing an extra wizard page. + + :Mandatory: Yes + :Default: ``ON`` + +.. variable:: CPACK_INNOSETUP_PROGRAM_MENU_FOLDER + + The initial name of the start menu folder being created. + + If this variable is set to ``.``, then no separate folder is created, + application shortcuts will appear in the top-level start menu folder. + + :Mandatory: Yes + :Default: The value of :variable:`CPACK_PACKAGE_NAME` + +.. variable:: CPACK_INNOSETUP_LANGUAGES + + A :ref:`semicolon-separated list <CMake Language Lists>` of languages you want + Inno Setup to include. + + Currently available: ``armenian``, ``brazilianPortuguese``, ``bulgarian``, + ``catalan``, ``corsican``, ``czech``, ``danish``, ``dutch``, ``english``, + ``finnish``, ``french``, ``german``, ``hebrew``, ``icelandic``, ``italian``, + ``japanese``, ``norwegian``, ``polish``, ``portuguese``, ``russian``, + ``slovak``, ``slovenian``, ``spanish``, ``turkish`` and ``ukrainian``. + This list might differ depending on the version of Inno Setup. + + :Mandatory: Yes + :Default: ``english`` + +.. variable:: CPACK_INNOSETUP_IGNORE_LICENSE_PAGE + + If you don't specify a license file using + :variable:`CPACK_RESOURCE_FILE_LICENSE`, CPack uses a file for demonstration + purposes. If you want the installer to ignore license files at all, you can + enable this option. + + :Mandatory: Yes + :Default: ``OFF`` + +.. variable:: CPACK_INNOSETUP_IGNORE_README_PAGE + + If you don't specify a readme file using + :variable:`CPACK_RESOURCE_FILE_README`, CPack uses a file for demonstration + purposes. If you want the installer to ignore readme files at all, you can + enable this option. Make sure the option is disabled when using + a custom readme file. + + :Mandatory: Yes + :Default: ``ON`` + +.. variable:: CPACK_INNOSETUP_PASSWORD + + Enables password protection and file encryption with the given password. + + :Mandatory: No + +.. variable:: CPACK_INNOSETUP_USE_MODERN_WIZARD + + Enables the modern look and feel provided by Inno Setup. If this option is + turned off, the classic style is used instead. Images and icon files are + also affected. + + :Mandatory: Yes + :Default: ``OFF`` because of compatibility reasons + +.. variable:: CPACK_INNOSETUP_ICON_FILE + + The path to a custom installer ``.ico`` file. + + Use :variable:`CPACK_PACKAGE_ICON` to customize the bitmap file being shown + in the wizard. + + :Mandatory: No + +.. variable:: CPACK_INNOSETUP_SETUP_<directive> + + This group allows adapting any of the ``[Setup]`` section directives provided + by Inno Setup where ``directive`` is its name. + + Here are some examples: + + .. code-block:: cmake + + set(CPACK_INNOSETUP_SETUP_WizardSmallImageFile "my_bitmap.bmp") + set(CPACK_INNOSETUP_SETUP_AllowNoIcons OFF) # This requires CPACK_INNOSETUP_USE_CMAKE_BOOL_FORMAT to be on + + All of these variables have higher priority than the others. + Consider the following example: + + .. code-block:: cmake + + set(CPACK_INNOSETUP_SETUP_Password "admin") + set(CPACK_INNOSETUP_PASSWORD "secret") + + The password will be ``admin`` at the end because ``CPACK_INNOSETUP_PASSWORD`` + has less priority than ``CPACK_INNOSETUP_SETUP_Password``. + + :Mandatory: No + + +File Specific Variables +""""""""""""""""""""""" + +Although all files being installed by an :command:`install` instruction are +automatically processed and added to the installer, there are some variables +to customize the installation process. + +Before using executables (only ``.exe`` or ``.com``) in shortcuts +(e.g. :variable:`CPACK_CREATE_DESKTOP_LINKS`) or ``[Run]`` entries, you've to +add the raw file name (without path and extension) to +:variable:`CPACK_PACKAGE_EXECUTABLES` and create a start menu shortcut +for them. + +If you have two files with the same raw name (e.g. ``a/executable.exe`` and +``b/executable.com``), an entry in the section is created twice. This will +result in undefined behavior and is not recommended. + +.. variable:: CPACK_INNOSETUP_CUSTOM_INSTALL_INSTRUCTIONS + + This variable should contain a + :ref:`semicolon-separated list <CMake Language Lists>` of pairs ``path``, + ``instruction`` and can be used to customize the install command being + automatically created for each file or directory. + + CPack creates the following Inno Setup instruction for every file... + + .. code-block:: + + Source: "absolute\path\to\my_file.txt"; DestDir: "{app}"; Flags: ignoreversion + + ...and the following line for every directory: + + .. code-block:: + + Name: "{app}\my_folder" + + You might want to change the destination directory or the flags of + ``my_file.txt``. Since we can also provide a relative path, the line you'd + like to have, is the following: + + .. code-block:: + + Source: "my_file.txt"; DestDir: "{userdocs}"; Flags: ignoreversion uninsneveruninstall + + You would do this by using ``my_file.txt`` as ``path`` and + ``Source: "my_file.txt"; DestDir: "{userdocs}"; Flags: ignoreversion uninsneveruninstall`` + as ``instruction``. + + You've to take care of the `escaping problem <https://cmake.org/cmake/help/book/mastering-cmake/chapter/Packaging%20With%20CPack.html#adding-custom-cpack-options>`_. + So the CMake command would be: + + .. code-block:: cmake + + set(CPACK_INNOSETUP_CUSTOM_INSTALL_INSTRUCTIONS "my_file.txt;Source: \\\"my_file.txt\\\"\\; DestDir: \\\"{userdocs}\\\"\\; Flags: ignoreversion uninsneveruninstall") + + To improve readability, you should go around the escaping problem by using + :variable:`CPACK_VERBATIM_VARIABLES` or by placing the instruction into a + separate CPack project config file. + + If you customize the install instruction of a specific file, you lose the + connection to its component. To go around, manually add + ``Components: <component>``. You also need to add its shortcuts and ``[Run]`` + entries by yourself in a custom section, since the executable won't be found + anymore by :variable:`CPACK_PACKAGE_EXECUTABLES`. + + Here's another example (Note: You've to go around the escaping problem for + the example to work): + + .. code-block:: cmake + + set(CPACK_INNOSETUP_CUSTOM_INSTALL_INSTRUCTIONS + "component1/my_folder" "Name: \"{userdocs}\\my_folder\"\; Components: component1" + "component2/my_folder2/my_file.txt" "Source: \"component2\\my_folder2\\my_file.txt\"\; DestDir: \"{app}\\my_folder2\\my_file.txt\"\; Flags: ignoreversion uninsneveruninstall\; Components: component2") + + :Mandatory: No + +.. variable:: CPACK_INNOSETUP_MENU_LINKS + + This variable should contain a + :ref:`semicolon-separated list <CMake Language Lists>` of pairs ``link``, + ``link name`` and can be used to add shortcuts into the start menu folder + beside those of the executables (see :variable:`CPACK_PACKAGE_EXECUTABLES`). + While ``link name`` is the label, ``link`` can be a URL or a path relative to + the installation directory. + + Here's an example: + + .. code-block:: cmake + + set(CPACK_INNOSETUP_MENU_LINKS + "doc/cmake-@CMake_VERSION_MAJOR@.@CMake_VERSION_MINOR@/cmake.html" + "CMake Help" "https://cmake.org" "CMake Web Site") + + :Mandatory: No + +.. variable:: CPACK_INNOSETUP_CREATE_UNINSTALL_LINK + + If this option is turned on, a shortcut to the application's uninstaller is + automatically added to the start menu folder. + + :Mandatory: Yes + :Default: ``OFF`` + +.. variable:: CPACK_INNOSETUP_RUN_EXECUTABLES + + A :ref:`semicolon-separated list <CMake Language Lists>` of executables being + specified in :variable:`CPACK_PACKAGE_EXECUTABLES` which the user can run + when the installer finishes. + + They're internally added to the ``[Run]`` section. + + :Mandatory: No + + +Components Specific Variables +""""""""""""""""""""""""""""" + +The generator supports components and also downloaded components. However, +there are some features of components that aren't supported yet (especially +component dependencies). These variables are ignored for now. + +CPack will change a component's name in Inno Setup if it has a parent group +for technical reasons. Consider using ``group\component`` as component name in +Inno Setup scripts if you have the component ``component`` and its parent +group ``group``. + +Here are some additional variables for components: + +.. variable:: CPACK_INNOSETUP_<compName>_INSTALL_DIRECTORY + + If you don't want the component ``compName`` to be installed under ``{app}``, + you've to specify its installation directory here. + + :Mandatory: No + +.. variable:: CPACK_INNOSETUP_VERIFY_DOWNLOADS + + This option only affects downloaded components. + + If this option is turned on, the hashes of the downloaded archives are + calculated during compile and + download time. The installer will only proceed if they match. + + :Mandatory: Yes + :Default: ``ON`` + + +Compilation and Scripting Specific Variables +"""""""""""""""""""""""""""""""""""""""""""" + +.. variable:: CPACK_INNOSETUP_EXECUTABLE + + The filename of the Inno Setup Script Compiler command. + + :Mandatory: Yes + :Default: ``ISCC`` + +.. variable:: CPACK_INNOSETUP_EXECUTABLE_ARGUMENTS + + A :ref:`semicolon-separated list <CMake Language Lists>` of extra + command-line options for the Inno Setup Script Compiler command. + + For example: ``/Qp;/Smysigntool=$p`` + + Take care of the `escaping problem <https://cmake.org/cmake/help/book/mastering-cmake/chapter/Packaging%20With%20CPack.html#adding-custom-cpack-options>`_. + + :Mandatory: No + +.. variable:: CPACK_INNOSETUP_DEFINE_<macro> + + This group allows to add custom define directives as command-line options to + the Inno Setup Preprocessor command. Each entry emulates a + ``#define public <macro>`` directive. Its macro is accessible from anywhere + (``public``), so it can also be used in extra script files. + + Macro names must not contain any special characters. Refer to the Inno Setup + Preprocessor documentation for the detailed rules. + + Consider the following example: + + .. code-block:: cmake + + # The following line emulates: #define public MyMacro "Hello, World!" + set(CPACK_INNOSETUP_DEFINE_MyMacro "Hello, World!") + + At this point, you can use ``MyMacro`` anywhere. For example in the following + extra script: + + .. code-block:: + + AppComments={#emit "'My Macro' has the value: " + MyMacro} + + Take care of the `escaping problem <https://cmake.org/cmake/help/book/mastering-cmake/chapter/Packaging%20With%20CPack.html#adding-custom-cpack-options>`_. + + :Mandatory: No + +.. variable:: CPACK_INNOSETUP_EXTRA_SCRIPTS + + A :ref:`semicolon-separated list <CMake Language Lists>` of paths to + additional ``.iss`` script files to be processed. + + They're internally included at the top of the output script file using a + ``#include`` directive. + + You can add any section in your file to extend the installer (e.g. adding + additional tasks or registry keys). Prefer using + :variable:`CPACK_INNOSETUP_SETUP_<directive>` when extending the + ``[Setup]`` section. + + :Mandatory: No + +.. variable:: CPACK_INNOSETUP_CODE_FILES + + A :ref:`semicolon-separated list <CMake Language Lists>` of paths to + additional Pascal files to be processed. + + This variable is actually the same as + :variable:`CPACK_INNOSETUP_EXTRA_SCRIPTS`, except you don't have to + add ``[Code]`` at the top of your file. Never change the current section in + a code file. This will result in undefined behavior! Treat them as normal + Pascal scripts instead. + + Code files are included at the very bottom of the output script. + + :Mandatory: No diff --git a/Help/envvar/CMAKE_APPBUNDLE_PATH.rst b/Help/envvar/CMAKE_APPBUNDLE_PATH.rst new file mode 100644 index 0000000..d80e08d --- /dev/null +++ b/Help/envvar/CMAKE_APPBUNDLE_PATH.rst @@ -0,0 +1,14 @@ +CMAKE_APPBUNDLE_PATH +-------------------- + +.. include:: ENV_VAR.txt + +The ``CMAKE_APPBUNDLE_PATH`` environment variable may be set to a list of +directories to be searched for macOS application bundles +by the :command:`find_program` and :command:`find_package` commands. + +This variable may hold a single directory or a list of directories separated +by ``:`` on UNIX or ``;`` on Windows (the same as the ``PATH`` environment +variable convention on those platforms). + +See also the :variable:`CMAKE_APPBUNDLE_PATH` CMake variable. diff --git a/Help/envvar/CMAKE_FRAMEWORK_PATH.rst b/Help/envvar/CMAKE_FRAMEWORK_PATH.rst new file mode 100644 index 0000000..f543132 --- /dev/null +++ b/Help/envvar/CMAKE_FRAMEWORK_PATH.rst @@ -0,0 +1,15 @@ +CMAKE_FRAMEWORK_PATH +-------------------- + +.. include:: ENV_VAR.txt + +The ``CMAKE_FRAMEWORK_PATH`` environment variable may be set to a list of +directories to be searched for macOS frameworks by the :command:`find_library`, +:command:`find_package`, :command:`find_path` and :command:`find_file` commands. + + +This variable may hold a single directory or a list of directories separated +by ``:`` on UNIX or ``;`` on Windows (the same as the ``PATH`` environment +variable convention on those platforms). + +See also the :variable:`CMAKE_FRAMEWORK_PATH` CMake variable. diff --git a/Help/envvar/CMAKE_INCLUDE_PATH.rst b/Help/envvar/CMAKE_INCLUDE_PATH.rst new file mode 100644 index 0000000..a42460d --- /dev/null +++ b/Help/envvar/CMAKE_INCLUDE_PATH.rst @@ -0,0 +1,13 @@ +CMAKE_INCLUDE_PATH +------------------ + +.. include:: ENV_VAR.txt + +The ``CMAKE_INCLUDE_PATH`` environment variable may be set to a list of +directories to be searched by the :command:`find_file` and :command:`find_path` commands. + +This variable may hold a single directory or a list of directories separated +by ``:`` on UNIX or ``;`` on Windows (the same as the ``PATH`` environment +variable convention on those platforms). + +See also the :variable:`CMAKE_INCLUDE_PATH` CMake variable. diff --git a/Help/envvar/CMAKE_LIBRARY_PATH.rst b/Help/envvar/CMAKE_LIBRARY_PATH.rst new file mode 100644 index 0000000..a51100d --- /dev/null +++ b/Help/envvar/CMAKE_LIBRARY_PATH.rst @@ -0,0 +1,13 @@ +CMAKE_LIBRARY_PATH +------------------ + +.. include:: ENV_VAR.txt + +The ``CMAKE_LIBRARY_PATH`` environment variable may be set to a list of +directories to be searched by the :command:`find_library` command. + +This variable may hold a single directory or a list of directories separated +by ``:`` on UNIX or ``;`` on Windows (the same as the ``PATH`` environment +variable convention on those platforms). + +See also the :variable:`CMAKE_LIBRARY_PATH` CMake variable. diff --git a/Help/envvar/CMAKE_PROGRAM_PATH.rst b/Help/envvar/CMAKE_PROGRAM_PATH.rst new file mode 100644 index 0000000..bfc7a30 --- /dev/null +++ b/Help/envvar/CMAKE_PROGRAM_PATH.rst @@ -0,0 +1,13 @@ +CMAKE_PROGRAM_PATH +------------------ + +.. include:: ENV_VAR.txt + +The ``CMAKE_PROGRAM_PATH`` environment variable may be set to a list of +directories to be searched by the :command:`find_program` command. + +This variable may hold a single directory or a list of directories separated +by ``:`` on UNIX or ``;`` on Windows (the same as the ``PATH`` environment +variable convention on those platforms). + +See also the :variable:`CMAKE_PROGRAM_PATH` CMake variable. diff --git a/Help/guide/tutorial/Adding Generator Expressions.rst b/Help/guide/tutorial/Adding Generator Expressions.rst index aba9f7a..3dab97f 100644 --- a/Help/guide/tutorial/Adding Generator Expressions.rst +++ b/Help/guide/tutorial/Adding Generator Expressions.rst @@ -27,168 +27,7 @@ expressions are the ``0`` and ``1`` expressions. A ``$<0:...>`` results in the empty string, and ``<1:...>`` results in the content of ``...``. They can also be nested. -Exercise 1 - Setting the C++ Standard with Interface Libraries -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Before we use :manual:`generator expressions <cmake-generator-expressions(7)>` -let's refactor our existing code to use an ``INTERFACE`` library. We will -use that library in the next step to demonstrate a common use for -:manual:`generator expressions <cmake-generator-expressions(7)>`. - -Goal ----- - -Add an ``INTERFACE`` library target to specify the required C++ standard. - -Helpful Resources ------------------ - -* :command:`add_library` -* :command:`target_compile_features` -* :command:`target_link_libraries` - -Files to Edit -------------- - -* ``CMakeLists.txt`` -* ``MathFunctions/CMakeLists.txt`` - -Getting Started ---------------- - -In this exercise, we will refactor our code to use an ``INTERFACE`` library to -specify the C++ standard. - -The starting source code is provided in the ``Step4`` directory. In this -exercise, complete ``TODO 1`` through ``TODO 3``. - -Start by editing the top level ``CMakeLists.txt`` file. Construct an -``INTERFACE`` library target called ``tutorial_compiler_flags`` and -specify ``cxx_std_11`` as a target compiler feature. - -Modify ``CMakeLists.txt`` and ``MathFunctions/CMakeLists.txt`` so that all -targets have a :command:`target_link_libraries` call to -``tutorial_compiler_flags``. - -Build and Run -------------- - -Make a new directory called ``Step4_build``, run the :manual:`cmake <cmake(1)>` -executable or the :manual:`cmake-gui <cmake-gui(1)>` to configure the project -and then build it with your chosen build tool or by using ``cmake --build .`` -from the build directory. - -Here's a refresher of what that looks like from the command line: - -.. code-block:: console - - mkdir Step4_build - cd Step4_build - cmake ../Step4 - cmake --build . - -Next, use the newly built ``Tutorial`` and verify that it is working as -expected. - -Solution --------- - -Let's update our code from the previous step to use interface libraries -to set our C++ requirements. - -To start, we need to remove the two :command:`set` calls on the variables -:variable:`CMAKE_CXX_STANDARD` and :variable:`CMAKE_CXX_STANDARD_REQUIRED`. -The specific lines to remove are as follows: - -.. literalinclude:: Step4/CMakeLists.txt - :caption: CMakeLists.txt - :name: CMakeLists.txt-CXX_STANDARD-variable-remove - :language: cmake - :start-after: # specify the C++ standard - :end-before: # TODO 6: Create helper variables - -Next, we need to create an interface library, ``tutorial_compiler_flags``. And -then use :command:`target_compile_features` to add the compiler feature -``cxx_std_11``. - - -.. raw:: html - - <details><summary>TODO 1: Click to show/hide answer</summary> - -.. literalinclude:: Step5/CMakeLists.txt - :caption: TODO 1: CMakeLists.txt - :name: CMakeLists.txt-cxx_std-feature - :language: cmake - :start-after: # specify the C++ standard - :end-before: # add compiler warning flags just - -.. raw:: html - - </details> - -Finally, with our interface library set up, we need to link our -executable ``Target``, our ``MathFunctions`` library, and our ``SqrtLibrary`` -library to our new -``tutorial_compiler_flags`` library. Respectively, the code will look like -this: - -.. raw:: html - - <details><summary>TODO 2: Click to show/hide answer</summary> - -.. literalinclude:: Step5/CMakeLists.txt - :caption: TODO 2: CMakeLists.txt - :name: CMakeLists.txt-target_link_libraries-step4 - :language: cmake - :start-after: add_executable(Tutorial tutorial.cxx) - :end-before: # add the binary tree to the search path for include file - -.. raw:: html - - </details> - -this: - -.. raw:: html - - <details><summary>TODO 3: Click to show/hide answer</summary> - -.. literalinclude:: Step5/MathFunctions/CMakeLists.txt - :caption: TODO 3: MathFunctions/CMakeLists.txt - :name: MathFunctions-CMakeLists.txt-target_link_libraries-step4 - :language: cmake - :start-after: # link our compiler flags interface library - :end-before: target_link_libraries(MathFunctions - -.. raw:: html - - </details> - -and this: - -.. raw:: html - - <details><summary>TODO 4: Click to show/hide answer</summary> - -.. literalinclude:: Step5/MathFunctions/CMakeLists.txt - :caption: TODO 4: MathFunctions/CMakeLists.txt - :name: MathFunctions-SqrtLibrary-target_link_libraries-step4 - :language: cmake - :start-after: target_link_libraries(SqrtLibrary - :end-before: endif() - -.. raw:: html - - </details> - - -With this, all of our code still requires C++ 11 to build. Notice -though that with this method, it gives us the ability to be specific about -which targets get specific requirements. In addition, we create a single -source of truth in our interface library. - -Exercise 2 - Adding Compiler Warning Flags with Generator Expressions +Exercise 1 - Adding Compiler Warning Flags with Generator Expressions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ A common usage of @@ -218,8 +57,8 @@ Files to Edit Getting Started --------------- -Start with the resulting files from Exercise 1. Complete ``TODO 5`` through -``TODO 8``. +Open the file ``Step4/CMakeLists.txt`` and complete ``TODO 1`` through +``TODO 4``. First, in the top level ``CMakeLists.txt`` file, we need to set the :command:`cmake_minimum_required` to ``3.15``. In this exercise we are going @@ -233,12 +72,16 @@ given a language and a set of compiler ids. Build and Run ------------- -Since we have our build directory already configured from Exercise 1, simply -rebuild our code by calling the following: +Make a new directory called ``Step4_build``, run the :manual:`cmake <cmake(1)>` +executable or the :manual:`cmake-gui <cmake-gui(1)>` to configure the project +and then build it with your chosen build tool or by using ``cmake --build .`` +from the build directory. .. code-block:: console + mkdir Step4_build cd Step4_build + cmake ../Step4 cmake --build . Solution @@ -249,10 +92,10 @@ version ``3.15``: .. raw:: html - <details><summary>TODO 5: Click to show/hide answer</summary> + <details><summary>TODO 1: Click to show/hide answer</summary> .. literalinclude:: Step5/CMakeLists.txt - :caption: TODO 5: CMakeLists.txt + :caption: TODO 1: CMakeLists.txt :name: MathFunctions-CMakeLists.txt-minimum-required-step4 :language: cmake :end-before: # set the project name and version @@ -268,10 +111,10 @@ variables ``gcc_like_cxx`` and ``msvc_cxx`` as follows: .. raw:: html - <details><summary>TODO 6: Click to show/hide answer</summary> + <details><summary>TODO 2: Click to show/hide answer</summary> .. literalinclude:: Step5/CMakeLists.txt - :caption: TODO 6: CMakeLists.txt + :caption: TODO 2: CMakeLists.txt :name: CMakeLists.txt-compile_lang_and_id :language: cmake :start-after: # the BUILD_INTERFACE genex @@ -289,10 +132,10 @@ interface library. .. raw:: html - <details><summary>TODO 7: Click to show/hide answer</summary> + <details><summary>TODO 3: Click to show/hide answer</summary> .. code-block:: cmake - :caption: TODO 7: CMakeLists.txt + :caption: TODO 3: CMakeLists.txt :name: CMakeLists.txt-compile_flags target_compile_options(tutorial_compiler_flags INTERFACE @@ -311,10 +154,10 @@ condition. The resulting full code looks like the following: .. raw:: html - <details><summary>TODO 8: Click to show/hide answer</summary> + <details><summary>TODO 4: Click to show/hide answer</summary> .. literalinclude:: Step5/CMakeLists.txt - :caption: TODO 8: CMakeLists.txt + :caption: TODO 4: CMakeLists.txt :name: CMakeLists.txt-target_compile_options-genex :language: cmake :start-after: set(msvc_cxx "$<COMPILE_LANG_AND_ID:CXX,MSVC>") diff --git a/Help/guide/tutorial/Adding Usage Requirements for a Library.rst b/Help/guide/tutorial/Adding Usage Requirements for a Library.rst index 74b7496..2273063 100644 --- a/Help/guide/tutorial/Adding Usage Requirements for a Library.rst +++ b/Help/guide/tutorial/Adding Usage Requirements for a Library.rst @@ -100,7 +100,7 @@ follows: :name: MathFunctions/CMakeLists.txt-target_include_directories-INTERFACE :language: cmake :start-after: # to find MathFunctions.h - :end-before: option + :end-before: # should we use our own .. raw:: html @@ -108,24 +108,26 @@ follows: Now that we've specified usage requirements for ``MathFunctions`` we can safely remove our uses of the ``EXTRA_INCLUDES`` variable from the top-level -``CMakeLists.txt``, here: +``CMakeLists.txt``. + +Remove this line: .. raw:: html <details><summary>TODO 2: Click to show/hide answer</summary> -.. literalinclude:: Step4/CMakeLists.txt +.. literalinclude:: Step3/CMakeLists.txt :caption: TODO 2: CMakeLists.txt :name: CMakeLists.txt-remove-EXTRA_INCLUDES :language: cmake - :start-after: # add the MathFunctions library - :end-before: # TODO 2: Link to tutorial_compiler_flags + :start-after: add_subdirectory(MathFunctions) + :end-before: # add the executable .. raw:: html </details> -And here: +And the lines: .. raw:: html @@ -141,7 +143,181 @@ And here: </details> +The remaining code looks like: + +.. raw:: html + + <details><summary>Click to show/hide the resulting code</summary> + +.. literalinclude:: Step4/CMakeLists.txt + :caption: Remaining code after removing EXTRA_INCLUDES + :name: CMakeLists.txt-after-removing-EXTRA_INCLUDES + :language: cmake + :start-after: add_subdirectory(MathFunctions) + +.. raw:: html + + </details> + + Notice that with this technique, the only thing our executable target does to use our library is call :command:`target_link_libraries` with the name of the library target. In larger projects, the classic method of specifying library dependencies manually becomes very complicated very quickly. + +Exercise 2 - Setting the C++ Standard with Interface Libraries +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Now that we have switched our code to a more modern approach, let's demonstrate +a modern technique to set properties to multiple targets. + +Let's refactor our existing code to use an ``INTERFACE`` library. We will +use that library in the next step to demonstrate a common use for +:manual:`generator expressions <cmake-generator-expressions(7)>`. + +Goal +---- + +Add an ``INTERFACE`` library target to specify the required C++ standard. + +Helpful Resources +----------------- + +* :command:`add_library` +* :command:`target_compile_features` +* :command:`target_link_libraries` + +Files to Edit +------------- + +* ``CMakeLists.txt`` +* ``MathFunctions/CMakeLists.txt`` + +Getting Started +--------------- + +In this exercise, we will refactor our code to use an ``INTERFACE`` library to +specify the C++ standard. + +Start this exercise from what we left at the end of Step3 exercise 1. You will +have to complete ``TODO 4`` through ``TODO 7``. + +Start by editing the top level ``CMakeLists.txt`` file. Construct an +``INTERFACE`` library target called ``tutorial_compiler_flags`` and +specify ``cxx_std_11`` as a target compiler feature. + +Modify ``CMakeLists.txt`` and ``MathFunctions/CMakeLists.txt`` so that all +targets have a :command:`target_link_libraries` call to +``tutorial_compiler_flags``. + +Build and Run +------------- + +Since we have our build directory already configured from Exercise 1, simply +rebuild our code by calling the following: + +.. code-block:: console + + cd Step3_build + cmake --build . + +Next, use the newly built ``Tutorial`` and verify that it is working as +expected. + +Solution +-------- + +Let's update our code from the previous step to use interface libraries +to set our C++ requirements. + +To start, we need to remove the two :command:`set` calls on the variables +:variable:`CMAKE_CXX_STANDARD` and :variable:`CMAKE_CXX_STANDARD_REQUIRED`. +The specific lines to remove are as follows: + +.. literalinclude:: Step3/CMakeLists.txt + :caption: CMakeLists.txt + :name: CMakeLists.txt-CXX_STANDARD-variable-remove + :language: cmake + :start-after: # specify the C++ standard + :end-before: # configure a header file + +Next, we need to create an interface library, ``tutorial_compiler_flags``. And +then use :command:`target_compile_features` to add the compiler feature +``cxx_std_11``. + + +.. raw:: html + + <details><summary>TODO 4: Click to show/hide answer</summary> + +.. literalinclude:: Step4/CMakeLists.txt + :caption: TODO 4: CMakeLists.txt + :name: CMakeLists.txt-cxx_std-feature + :language: cmake + :start-after: # specify the C++ standard + :end-before: # TODO 2: Create helper + +.. raw:: html + + </details> + +Finally, with our interface library set up, we need to link our +executable ``Target``, our ``MathFunctions`` library, and our ``SqrtLibrary`` +library to our new +``tutorial_compiler_flags`` library. Respectively, the code will look like +this: + +.. raw:: html + + <details><summary>TODO 5: Click to show/hide answer</summary> + +.. literalinclude:: Step4/CMakeLists.txt + :caption: TODO 5: CMakeLists.txt + :name: CMakeLists.txt-target_link_libraries-step4 + :language: cmake + :start-after: add_executable(Tutorial tutorial.cxx) + :end-before: # add the binary tree to the search path for include file + +.. raw:: html + + </details> + +this: + +.. raw:: html + + <details><summary>TODO 6: Click to show/hide answer</summary> + +.. literalinclude:: Step4/MathFunctions/CMakeLists.txt + :caption: TODO 6: MathFunctions/CMakeLists.txt + :name: MathFunctions-CMakeLists.txt-target_link_libraries-step4 + :language: cmake + :start-after: # link our compiler flags interface library + :end-before: target_link_libraries(MathFunctions + +.. raw:: html + + </details> + +and this: + +.. raw:: html + + <details><summary>TODO 7: Click to show/hide answer</summary> + +.. literalinclude:: Step4/MathFunctions/CMakeLists.txt + :caption: TODO 7: MathFunctions/CMakeLists.txt + :name: MathFunctions-SqrtLibrary-target_link_libraries-step4 + :language: cmake + :start-after: target_link_libraries(SqrtLibrary + :end-before: endif() + +.. raw:: html + + </details> + + +With this, all of our code still requires C++ 11 to build. Notice +though that with this method, it gives us the ability to be specific about +which targets get specific requirements. In addition, we create a single +source of truth in our interface library. diff --git a/Help/guide/tutorial/Adding a Library.rst b/Help/guide/tutorial/Adding a Library.rst index d606f30..694dfaf 100644 --- a/Help/guide/tutorial/Adding a Library.rst +++ b/Help/guide/tutorial/Adding a Library.rst @@ -409,7 +409,7 @@ that has sources ``mysqrt.cxx``. :name: MathFunctions/CMakeLists.txt-add_library-SqrtLibrary :language: cmake :start-after: # library that just does sqrt - :end-before: target_link_libraries(MathFunctions + :end-before: # TODO 7: Link .. raw:: html @@ -426,7 +426,8 @@ enabled. :caption: TODO 13 : MathFunctions/CMakeLists.txt :name: MathFunctions/CMakeLists.txt-target_link_libraries-SqrtLibrary :language: cmake - :lines: 16-18 + :start-after: to tutorial_compiler_flags + :end-before: endif() .. raw:: html diff --git a/Help/guide/tutorial/Step3/CMakeLists.txt b/Help/guide/tutorial/Step3/CMakeLists.txt index f051826..ac3e9f1 100644 --- a/Help/guide/tutorial/Step3/CMakeLists.txt +++ b/Help/guide/tutorial/Step3/CMakeLists.txt @@ -3,6 +3,12 @@ cmake_minimum_required(VERSION 3.10) # set the project name and version project(Tutorial VERSION 1.0) +# TODO 4: Replace the following code by: +# * Creating an interface library called tutorial_compiler_flags +# Hint: use add_library() with the INTERFACE signature +# * Add compiler feature cxx_std_11 to tutorial_compiler_flags +# Hint: Use target_compile_features() + # specify the C++ standard set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED True) @@ -20,6 +26,8 @@ list(APPEND EXTRA_INCLUDES "${PROJECT_SOURCE_DIR}/MathFunctions") # add the executable add_executable(Tutorial tutorial.cxx) +# TODO 5: Link Tutorial to tutorial_compiler_flags + target_link_libraries(Tutorial PUBLIC MathFunctions) # TODO 3: Remove use of EXTRA_INCLUDES diff --git a/Help/guide/tutorial/Step3/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step3/MathFunctions/CMakeLists.txt index 6f86ffe..0ffb9e1 100644 --- a/Help/guide/tutorial/Step3/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step3/MathFunctions/CMakeLists.txt @@ -14,5 +14,9 @@ if (USE_MYMATH) mysqrt.cxx ) + # TODO 7: Link SqrtLibrary to tutorial_compiler_flags + target_link_libraries(MathFunctions PUBLIC SqrtLibrary) endif() + +# TODO 6: Link MathFunctions to tutorial_compiler_flags diff --git a/Help/guide/tutorial/Step4/CMakeLists.txt b/Help/guide/tutorial/Step4/CMakeLists.txt index 7531fb4..fba9766 100644 --- a/Help/guide/tutorial/Step4/CMakeLists.txt +++ b/Help/guide/tutorial/Step4/CMakeLists.txt @@ -1,33 +1,27 @@ -# TODO 5: Update the minimum required version to 3.15 +# TODO 1: Update the minimum required version to 3.15 cmake_minimum_required(VERSION 3.10) # set the project name and version project(Tutorial VERSION 1.0) -# TODO 1: Replace the following code by: -# * Creating an interface library called tutorial_compiler_flags -# Hint: use add_library() with the INTERFACE signature -# * Add compiler feature cxx_std_11 to tutorial_compiler_flags -# Hint: Use target_compile_features() - # specify the C++ standard -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED True) +add_library(tutorial_compiler_flags INTERFACE) +target_compile_features(tutorial_compiler_flags INTERFACE cxx_std_11) -# TODO 6: Create helper variables to determine which compiler we are using: +# TODO 2: Create helper variables to determine which compiler we are using: # * Create a new variable gcc_like_cxx that is true if we are using CXX and # any of the following compilers: ARMClang, AppleClang, Clang, GNU, LCC # * Create a new variable msvc_cxx that is true if we are using CXX and MSVC # Hint: Use set() and COMPILE_LANG_AND_ID -# TODO 7: Add warning flag compile options to the interface library +# TODO 3: Add warning flag compile options to the interface library # tutorial_compiler_flags. # * For gcc_like_cxx, add flags -Wall;-Wextra;-Wshadow;-Wformat=2;-Wunused # * For msvc_cxx, add flags -W3 # Hint: Use target_compile_options() -# TODO 8: With nested generator expressions, only use the flags for the +# TODO 4: With nested generator expressions, only use the flags for the # build-tree # Hint: Use BUILD_INTERFACE @@ -41,9 +35,7 @@ add_subdirectory(MathFunctions) # add the executable add_executable(Tutorial tutorial.cxx) -# TODO 2: Link to tutorial_compiler_flags - -target_link_libraries(Tutorial PUBLIC MathFunctions) +target_link_libraries(Tutorial PUBLIC MathFunctions tutorial_compiler_flags) # add the binary tree to the search path for include files # so that we will find TutorialConfig.h diff --git a/Help/guide/tutorial/Step4/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step4/MathFunctions/CMakeLists.txt index ffab4f0..48561eb 100644 --- a/Help/guide/tutorial/Step4/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step4/MathFunctions/CMakeLists.txt @@ -17,9 +17,10 @@ if (USE_MYMATH) mysqrt.cxx ) - # TODO 4: Link to tutorial_compiler_flags - + # link our compiler flags interface library + target_link_libraries(SqrtLibrary PUBLIC tutorial_compiler_flags) target_link_libraries(MathFunctions PUBLIC SqrtLibrary) endif() -# TODO 3: Link to tutorial_compiler_flags +# link our compiler flags interface library +target_link_libraries(MathFunctions PUBLIC tutorial_compiler_flags) diff --git a/Help/manual/cmake-env-variables.7.rst b/Help/manual/cmake-env-variables.7.rst index 1f0c911..f7ae94d 100644 --- a/Help/manual/cmake-env-variables.7.rst +++ b/Help/manual/cmake-env-variables.7.rst @@ -20,8 +20,13 @@ Environment Variables that Change Behavior .. toctree:: :maxdepth: 1 + /envvar/CMAKE_APPBUNDLE_PATH + /envvar/CMAKE_FRAMEWORK_PATH + /envvar/CMAKE_INCLUDE_PATH + /envvar/CMAKE_LIBRARY_PATH /envvar/CMAKE_MAXIMUM_RECURSION_DEPTH /envvar/CMAKE_PREFIX_PATH + /envvar/CMAKE_PROGRAM_PATH /envvar/SSL_CERT_DIR /envvar/SSL_CERT_FILE diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 7c5a654..8b055b0 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -536,6 +536,10 @@ Variables that Control the Build /variable/CMAKE_USE_RELATIVE_PATHS /variable/CMAKE_VERIFY_INTERFACE_HEADER_SETS /variable/CMAKE_VISIBILITY_INLINES_HIDDEN + /variable/CMAKE_VS_DEBUGGER_COMMAND + /variable/CMAKE_VS_DEBUGGER_COMMAND_ARGUMENTS + /variable/CMAKE_VS_DEBUGGER_ENVIRONMENT + /variable/CMAKE_VS_DEBUGGER_WORKING_DIRECTORY /variable/CMAKE_VS_GLOBALS /variable/CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD /variable/CMAKE_VS_INCLUDE_PACKAGE_TO_DEFAULT_BUILD diff --git a/Help/manual/cpack-generators.7.rst b/Help/manual/cpack-generators.7.rst index ade9149..abb291b 100644 --- a/Help/manual/cpack-generators.7.rst +++ b/Help/manual/cpack-generators.7.rst @@ -20,6 +20,7 @@ Generators /cpack_gen/dmg /cpack_gen/external /cpack_gen/freebsd + /cpack_gen/innosetup /cpack_gen/ifw /cpack_gen/nsis /cpack_gen/nuget diff --git a/Help/prop_tgt/VS_DEBUGGER_COMMAND.rst b/Help/prop_tgt/VS_DEBUGGER_COMMAND.rst index 1e84c00..5bf47a3 100644 --- a/Help/prop_tgt/VS_DEBUGGER_COMMAND.rst +++ b/Help/prop_tgt/VS_DEBUGGER_COMMAND.rst @@ -7,7 +7,9 @@ Sets the local debugger command for Visual Studio C++ targets. The property value may use :manual:`generator expressions <cmake-generator-expressions(7)>`. This is defined in ``<LocalDebuggerCommand>`` in the Visual Studio -project file. +project file. This property is initialized by the value of the variable +:variable:`CMAKE_VS_DEBUGGER_COMMAND` if it is set when a target is +created. This property only works for Visual Studio 11 2012 and above; it is ignored on other generators. diff --git a/Help/prop_tgt/VS_DEBUGGER_COMMAND_ARGUMENTS.rst b/Help/prop_tgt/VS_DEBUGGER_COMMAND_ARGUMENTS.rst index e54e140..4b9dff7 100644 --- a/Help/prop_tgt/VS_DEBUGGER_COMMAND_ARGUMENTS.rst +++ b/Help/prop_tgt/VS_DEBUGGER_COMMAND_ARGUMENTS.rst @@ -7,7 +7,9 @@ Sets the local debugger command line arguments for Visual Studio C++ targets. The property value may use :manual:`generator expressions <cmake-generator-expressions(7)>`. This is defined in ``<LocalDebuggerCommandArguments>`` in the Visual Studio -project file. +project file. This property is initialized by the value of the variable +:variable:`CMAKE_VS_DEBUGGER_COMMAND_ARGUMENTS` if it is set when a target is +created. This property only works for Visual Studio 11 2012 and above; it is ignored on other generators. diff --git a/Help/prop_tgt/VS_DEBUGGER_ENVIRONMENT.rst b/Help/prop_tgt/VS_DEBUGGER_ENVIRONMENT.rst index 60bc2f0..8373dbb 100644 --- a/Help/prop_tgt/VS_DEBUGGER_ENVIRONMENT.rst +++ b/Help/prop_tgt/VS_DEBUGGER_ENVIRONMENT.rst @@ -7,7 +7,9 @@ Sets the local debugger environment for Visual Studio C++ targets. The property value may use :manual:`generator expressions <cmake-generator-expressions(7)>`. This is defined in ``<LocalDebuggerEnvironment>`` in the Visual Studio -project file. +project file. This property is initialized by the value of the variable +:variable:`CMAKE_VS_DEBUGGER_ENVIRONMENT` if it is set when a target is +created. This property only works for Visual Studio 11 2012 and above; it is ignored on other generators. diff --git a/Help/prop_tgt/VS_DEBUGGER_WORKING_DIRECTORY.rst b/Help/prop_tgt/VS_DEBUGGER_WORKING_DIRECTORY.rst index f9ce7aa..3942047 100644 --- a/Help/prop_tgt/VS_DEBUGGER_WORKING_DIRECTORY.rst +++ b/Help/prop_tgt/VS_DEBUGGER_WORKING_DIRECTORY.rst @@ -7,7 +7,9 @@ Sets the local debugger working directory for Visual Studio C++ targets. The property value may use :manual:`generator expressions <cmake-generator-expressions(7)>`. This is defined in ``<LocalDebuggerWorkingDirectory>`` in the Visual Studio -project file. +project file. This property is initialized by the value of the variable +:variable:`CMAKE_VS_DEBUGGER_WORKING_DIRECTORY` if it is set when a target is +created. This property only works for Visual Studio 11 2012 and above; it is ignored on other generators. diff --git a/Help/release/dev/FindDoxygen-custom-config-file.rst b/Help/release/dev/FindDoxygen-custom-config-file.rst new file mode 100644 index 0000000..badc26e --- /dev/null +++ b/Help/release/dev/FindDoxygen-custom-config-file.rst @@ -0,0 +1,5 @@ +FindDoxygen-custom-config-file +------------------------------ + +* The :module:`FindDoxygen` module's ``doxygen_add_docs`` command gained + a ``CONFIG_FILE`` option to specify a custom doxygen configuration file. diff --git a/Help/release/dev/cpack-innosetup.rst b/Help/release/dev/cpack-innosetup.rst new file mode 100644 index 0000000..a9f8e8e --- /dev/null +++ b/Help/release/dev/cpack-innosetup.rst @@ -0,0 +1,12 @@ +cpack-innosetup +--------------- + +* The :cpack_gen:`CPack Inno Setup Generator` was added to package using + Inno Setup. + + The new generator adds: + + * A lot of options to customize the Inno Setup installer (e.g. custom + installation rules) + * Start menu and desktop shortcuts + * Components (and also downloaded components) diff --git a/Help/release/dev/vs-debugger-init.rst b/Help/release/dev/vs-debugger-init.rst new file mode 100644 index 0000000..aa86839 --- /dev/null +++ b/Help/release/dev/vs-debugger-init.rst @@ -0,0 +1,8 @@ +vs-debugger-init +---------------- + +* Variables :variable:`CMAKE_VS_DEBUGGER_COMMAND`, + :variable:`CMAKE_VS_DEBUGGER_COMMAND_ARGUMENTS`, + :variable:`CMAKE_VS_DEBUGGER_ENVIRONMENT`, and + :variable:`CMAKE_VS_DEBUGGER_WORKING_DIRECTORY` were added to initialize + corresponding target properties. diff --git a/Help/variable/CMAKE_APPBUNDLE_PATH.rst b/Help/variable/CMAKE_APPBUNDLE_PATH.rst index 1c7ca51..441ee8e 100644 --- a/Help/variable/CMAKE_APPBUNDLE_PATH.rst +++ b/Help/variable/CMAKE_APPBUNDLE_PATH.rst @@ -4,3 +4,6 @@ CMAKE_APPBUNDLE_PATH :ref:`Semicolon-separated list <CMake Language Lists>` of directories specifying a search path for macOS application bundles used by the :command:`find_program`, and :command:`find_package` commands. + +There is also an environment variable :envvar:`CMAKE_APPBUNDLE_PATH`, which is used +as an additional list of search directories. diff --git a/Help/variable/CMAKE_FRAMEWORK_PATH.rst b/Help/variable/CMAKE_FRAMEWORK_PATH.rst index 13ade4e..8d62b02 100644 --- a/Help/variable/CMAKE_FRAMEWORK_PATH.rst +++ b/Help/variable/CMAKE_FRAMEWORK_PATH.rst @@ -5,3 +5,6 @@ CMAKE_FRAMEWORK_PATH for macOS frameworks used by the :command:`find_library`, :command:`find_package`, :command:`find_path`, and :command:`find_file` commands. + +There is also an environment variable :envvar:`CMAKE_FRAMEWORK_PATH`, which is used +as an additional list of search directories. diff --git a/Help/variable/CMAKE_INCLUDE_PATH.rst b/Help/variable/CMAKE_INCLUDE_PATH.rst index 4918e99..3a4472a 100644 --- a/Help/variable/CMAKE_INCLUDE_PATH.rst +++ b/Help/variable/CMAKE_INCLUDE_PATH.rst @@ -3,5 +3,10 @@ CMAKE_INCLUDE_PATH :ref:`Semicolon-separated list <CMake Language Lists>` of directories specifying a search path for the :command:`find_file` and :command:`find_path` commands. By default it -is empty, it is intended to be set by the project. See also -:variable:`CMAKE_SYSTEM_INCLUDE_PATH` and :variable:`CMAKE_PREFIX_PATH`. +is empty, it is intended to be set by the project. + + +There is also an environment variable :envvar:`CMAKE_INCLUDE_PATH`, which is used +as an additional list of search directories. + +See also :variable:`CMAKE_SYSTEM_INCLUDE_PATH` and :variable:`CMAKE_PREFIX_PATH`. diff --git a/Help/variable/CMAKE_LANG_COMPILER_ID.rst b/Help/variable/CMAKE_LANG_COMPILER_ID.rst index 3b27fc3..5eb86c6 100644 --- a/Help/variable/CMAKE_LANG_COMPILER_ID.rst +++ b/Help/variable/CMAKE_LANG_COMPILER_ID.rst @@ -9,7 +9,7 @@ include: =============================== =============================================== Value Name =============================== =============================================== -``Absoft`` `Absoft Fortran`_ +``Absoft`` Absoft Fortran ``ADSP`` Analog VisualDSP++ ``AppleClang`` Apple Clang ``ARMCC`` ARM Compiler @@ -50,7 +50,6 @@ Value Name This variable is not guaranteed to be defined for all compilers or languages. -.. _Absoft Fortran: https://www.absoft.com .. _LLVM Clang: https://clang.llvm.org .. _Embarcadero: https://www.embarcadero.com .. _Classic Flang Fortran Compiler: https://github.com/flang-compiler/flang diff --git a/Help/variable/CMAKE_LIBRARY_PATH.rst b/Help/variable/CMAKE_LIBRARY_PATH.rst index 8135b65..4265982 100644 --- a/Help/variable/CMAKE_LIBRARY_PATH.rst +++ b/Help/variable/CMAKE_LIBRARY_PATH.rst @@ -3,5 +3,9 @@ CMAKE_LIBRARY_PATH :ref:`Semicolon-separated list <CMake Language Lists>` of directories specifying a search path for the :command:`find_library` command. By default it is empty, it is -intended to be set by the project. See also -:variable:`CMAKE_SYSTEM_LIBRARY_PATH` and :variable:`CMAKE_PREFIX_PATH`. +intended to be set by the project. + +There is also an environment variable :envvar:`CMAKE_LIBRARY_PATH`, which is used +as an additional list of search directories. + +See also :variable:`CMAKE_SYSTEM_LIBRARY_PATH` and :variable:`CMAKE_PREFIX_PATH`. diff --git a/Help/variable/CMAKE_PREFIX_PATH.rst b/Help/variable/CMAKE_PREFIX_PATH.rst index 1d4fd0b..54f2aec 100644 --- a/Help/variable/CMAKE_PREFIX_PATH.rst +++ b/Help/variable/CMAKE_PREFIX_PATH.rst @@ -10,6 +10,9 @@ documentation. By default this is empty. It is intended to be set by the project. +There is also an environment variable :envvar:`CMAKE_PREFIX_PATH`, which is used +as an additional list of search prefixes. + See also :variable:`CMAKE_SYSTEM_PREFIX_PATH`, :variable:`CMAKE_INCLUDE_PATH`, :variable:`CMAKE_LIBRARY_PATH`, :variable:`CMAKE_PROGRAM_PATH`, and :variable:`CMAKE_IGNORE_PATH`. diff --git a/Help/variable/CMAKE_PROGRAM_PATH.rst b/Help/variable/CMAKE_PROGRAM_PATH.rst index 2d0c090..240bacb 100644 --- a/Help/variable/CMAKE_PROGRAM_PATH.rst +++ b/Help/variable/CMAKE_PROGRAM_PATH.rst @@ -3,5 +3,9 @@ CMAKE_PROGRAM_PATH :ref:`Semicolon-separated list <CMake Language Lists>` of directories specifying a search path for the :command:`find_program` command. By default it is empty, it is -intended to be set by the project. See also -:variable:`CMAKE_SYSTEM_PROGRAM_PATH` and :variable:`CMAKE_PREFIX_PATH`. +intended to be set by the project. + +There is also an environment variable :envvar:`CMAKE_PROGRAM_PATH`, which is used +as an additional list of search directories. + +See also :variable:`CMAKE_SYSTEM_PROGRAM_PATH` and :variable:`CMAKE_PREFIX_PATH`. diff --git a/Help/variable/CMAKE_VS_DEBUGGER_COMMAND.rst b/Help/variable/CMAKE_VS_DEBUGGER_COMMAND.rst new file mode 100644 index 0000000..b2c03a1 --- /dev/null +++ b/Help/variable/CMAKE_VS_DEBUGGER_COMMAND.rst @@ -0,0 +1,8 @@ +CMAKE_VS_DEBUGGER_COMMAND +------------------------- + +.. versionadded:: 3.27 + +This variable is used to initialize the :prop_tgt:`VS_DEBUGGER_COMMAND` +property on each target as it is created. See that target property +for additional information. diff --git a/Help/variable/CMAKE_VS_DEBUGGER_COMMAND_ARGUMENTS.rst b/Help/variable/CMAKE_VS_DEBUGGER_COMMAND_ARGUMENTS.rst new file mode 100644 index 0000000..482aa67 --- /dev/null +++ b/Help/variable/CMAKE_VS_DEBUGGER_COMMAND_ARGUMENTS.rst @@ -0,0 +1,8 @@ +CMAKE_VS_DEBUGGER_COMMAND_ARGUMENTS +----------------------------------- + +.. versionadded:: 3.27 + +This variable is used to initialize the :prop_tgt:`VS_DEBUGGER_COMMAND_ARGUMENTS` +property on each target as it is created. See that target property +for additional information. diff --git a/Help/variable/CMAKE_VS_DEBUGGER_ENVIRONMENT.rst b/Help/variable/CMAKE_VS_DEBUGGER_ENVIRONMENT.rst new file mode 100644 index 0000000..245ac5d --- /dev/null +++ b/Help/variable/CMAKE_VS_DEBUGGER_ENVIRONMENT.rst @@ -0,0 +1,8 @@ +CMAKE_VS_DEBUGGER_ENVIRONMENT +----------------------------- + +.. versionadded:: 3.27 + +This variable is used to initialize the :prop_tgt:`VS_DEBUGGER_ENVIRONMENT` +property on each target as it is created. See that target property +for additional information. diff --git a/Help/variable/CMAKE_VS_DEBUGGER_WORKING_DIRECTORY.rst b/Help/variable/CMAKE_VS_DEBUGGER_WORKING_DIRECTORY.rst new file mode 100644 index 0000000..9100adb --- /dev/null +++ b/Help/variable/CMAKE_VS_DEBUGGER_WORKING_DIRECTORY.rst @@ -0,0 +1,8 @@ +CMAKE_VS_DEBUGGER_WORKING_DIRECTORY +----------------------------------- + +.. versionadded:: 3.27 + +This variable is used to initialize the :prop_tgt:`VS_DEBUGGER_WORKING_DIRECTORY` +property on each target as it is created. See that target property +for additional information. diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index c4ddf75..9e38566 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -165,13 +165,13 @@ endif () if (NOT _CMAKE_TOOLCHAIN_PREFIX) - if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|Clang|QCC|LCC") + if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|QCC|LCC") get_filename_component(COMPILER_BASENAME "${CMAKE_CXX_COMPILER}" NAME) if (COMPILER_BASENAME MATCHES "^(.+-)?(clang\\+\\+|[gc]\\+\\+|clang-cl)(-[0-9]+(\\.[0-9]+)*)?(-[^.]+)?(\\.exe)?$") set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) set(_CMAKE_TOOLCHAIN_SUFFIX ${CMAKE_MATCH_3}) set(_CMAKE_COMPILER_SUFFIX ${CMAKE_MATCH_5}) - elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") if(CMAKE_CXX_COMPILER_TARGET) set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_CXX_COMPILER_TARGET}-) endif() @@ -186,7 +186,7 @@ if (NOT _CMAKE_TOOLCHAIN_PREFIX) if ("${_CMAKE_TOOLCHAIN_PREFIX}" MATCHES "(.+-)?llvm-$") set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) endif () - elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "TI") + elseif(CMAKE_CXX_COMPILER_ID MATCHES "TI") # TI compilers are named e.g. cl6x, cl470 or armcl.exe get_filename_component(COMPILER_BASENAME "${CMAKE_CXX_COMPILER}" NAME) if (COMPILER_BASENAME MATCHES "^(.+)?cl([^.]+)?(\\.exe)?$") diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake index f9cf33f..ff1cb7e 100644 --- a/Modules/CPack.cmake +++ b/Modules/CPack.cmake @@ -262,8 +262,8 @@ installers. The most commonly-used variables are: Lists each of the executables and associated text label to be used to create Start Menu shortcuts. For example, setting this to the list ``ccmake;CMake`` will create a shortcut named "CMake" that will execute the - installed executable :program:`ccmake`. Not all CPack generators use it (at least - NSIS, and WIX do). + installed executable :program:`ccmake`. Not all CPack generators use it (at least + NSIS, Inno Setup and WIX do). .. variable:: CPACK_STRIP_FILES @@ -738,14 +738,16 @@ if(NOT CPACK_GENERATOR) ) endif() else() - option(CPACK_BINARY_7Z "Enable to build 7-Zip packages" OFF) - option(CPACK_BINARY_NSIS "Enable to build NSIS packages" ON) - option(CPACK_BINARY_NUGET "Enable to build NuGet packages" OFF) - option(CPACK_BINARY_WIX "Enable to build WiX packages" OFF) - option(CPACK_BINARY_ZIP "Enable to build ZIP packages" OFF) + option(CPACK_BINARY_7Z "Enable to build 7-Zip packages" OFF) + option(CPACK_BINARY_NSIS "Enable to build NSIS packages" ON) + option(CPACK_BINARY_INNOSETUP "Enable to build Inno Setup packages" OFF) + option(CPACK_BINARY_NUGET "Enable to build NuGet packages" OFF) + option(CPACK_BINARY_WIX "Enable to build WiX packages" OFF) + option(CPACK_BINARY_ZIP "Enable to build ZIP packages" OFF) mark_as_advanced( CPACK_BINARY_7Z CPACK_BINARY_NSIS + CPACK_BINARY_INNOSETUP CPACK_BINARY_NUGET CPACK_BINARY_WIX CPACK_BINARY_ZIP @@ -762,6 +764,7 @@ if(NOT CPACK_GENERATOR) cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_FREEBSD FREEBSD) cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_IFW IFW) cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_NSIS NSIS) + cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_INNOSETUP INNOSETUP) cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_NUGET NuGet) cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_PRODUCTBUILD productbuild) cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_RPM RPM) @@ -869,6 +872,13 @@ if(NOT DEFINED CPACK_DMG_SLA_USE_RESOURCE_FILE_LICENSE unset(_CPack_CMP0133) endif() +# Inno Setup specific variables +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + _cpack_set_default(CPACK_INNOSETUP_ARCHITECTURE "x86") +elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) + _cpack_set_default(CPACK_INNOSETUP_ARCHITECTURE "x64") +endif() + # WiX specific variables _cpack_set_default(CPACK_WIX_SIZEOF_VOID_P "${CMAKE_SIZEOF_VOID_P}") diff --git a/Modules/Compiler/IAR.cmake b/Modules/Compiler/IAR.cmake index 0aca283..32a7b3f5 100644 --- a/Modules/Compiler/IAR.cmake +++ b/Modules/Compiler/IAR.cmake @@ -1,6 +1,6 @@ # This file is processed when the IAR C/C++ Compiler is used # -# CPU <arch> supported in CMake: 8051, Arm, AVR, MSP430, RH850, RISC-V, RL78, RX and V850 +# CPU <arch> supported in CMake: 8051, Arm, AVR, MSP430, RH850, RISC-V, RL78, RX, STM8 and V850 # # The compiler user documentation is architecture-dependent # and it can found with the product installation under <arch>/doc/{EW,BX}<arch>_DevelopmentGuide.ENU.pdf @@ -35,7 +35,9 @@ macro(__compiler_iar_ilink lang) __compiler_iar_common(${lang}) - set(CMAKE_${lang}_LINK_EXECUTABLE "<CMAKE_LINKER> --silent <OBJECTS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> -o <TARGET>") + string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " --silent") + set(CMAKE_${lang}_LINK_EXECUTABLE "<CMAKE_LINKER> <OBJECTS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> -o <TARGET>") + set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "<CMAKE_AR> <TARGET> --create <LINK_FLAGS> <OBJECTS>") set(CMAKE_${lang}_ARCHIVE_CREATE "<CMAKE_AR> <TARGET> --create <LINK_FLAGS> <OBJECTS>") set(CMAKE_${lang}_ARCHIVE_APPEND "<CMAKE_AR> <TARGET> --replace <LINK_FLAGS> <OBJECTS>") @@ -46,7 +48,9 @@ macro(__compiler_iar_xlink lang) __compiler_iar_common(${lang}) - set(CMAKE_${lang}_LINK_EXECUTABLE "<CMAKE_LINKER> -S <OBJECTS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> -o <TARGET>") + string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " -S") + set(CMAKE_${lang}_LINK_EXECUTABLE "<CMAKE_LINKER> <OBJECTS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> -o <TARGET>") + set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "<CMAKE_AR> <TARGET> <LINK_FLAGS> <OBJECTS>") set(CMAKE_${lang}_ARCHIVE_CREATE "<CMAKE_AR> <TARGET> <LINK_FLAGS> <OBJECTS>") set(CMAKE_${lang}_ARCHIVE_APPEND "") diff --git a/Modules/Compiler/NVHPC-Fortran.cmake b/Modules/Compiler/NVHPC-Fortran.cmake index 879c140..59755b3 100644 --- a/Modules/Compiler/NVHPC-Fortran.cmake +++ b/Modules/Compiler/NVHPC-Fortran.cmake @@ -1,4 +1,3 @@ include(Compiler/PGI-Fortran) include(Compiler/NVHPC) __compiler_nvhpc(Fortran) -set(CMAKE_Fortran_PREPROCESS_SOURCE_EXCLUDE_FLAGS_REGEX "(^| )-Werror([=,][a-z][a-z-]+)?( |$)") diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index 19bef94..39a1163 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -93,6 +93,11 @@ BLAS/LAPACK Vendors ``ACML``, ``ACML_MP``, ``ACML_GPU`` AMD Core Math Library +``AOCL``, ``AOCL_mt`` + .. versionadded:: 3.27 + + AMD Optimizing CPU Libraries + ``Apple``, ``NAS`` Apple BLAS (Accelerate), and Apple NAS (vecLib) @@ -848,6 +853,38 @@ if(BLA_VENDOR STREQUAL "FLAME" OR BLA_VENDOR STREQUAL "All") unset(_blas_flame_lib) endif() +# AOCL's blis library? (https://developer.amd.com/amd-aocl/) +if(BLA_VENDOR MATCHES "AOCL" OR BLA_VENDOR STREQUAL "All") + set(_blas_aocl_lib "blis") + + if(_blas_sizeof_integer EQUAL 8) + set(_blas_aocl_subdir "ILP64") + else() + set(_blas_aocl_subdir "LP64") + endif() + + # Check for multi-threaded support + if(BLA_VENDOR MATCHES "_mt") + string(APPEND _blas_aocl_lib "-mt") + endif() + + if(NOT BLAS_LIBRARIES) + check_blas_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "${_blas_aocl_lib}" + "" + "" + "${_blas_aocl_subdir}" + ) + endif() + + unset(_blas_aocl_lib) + unset(_blas_aocl_subdir) +endif() + # BLAS in the ATLAS library? (http://math-atlas.sourceforge.net/) if(BLA_VENDOR STREQUAL "ATLAS" OR BLA_VENDOR STREQUAL "All") if(NOT BLAS_LIBRARIES) diff --git a/Modules/FindCUDAToolkit.cmake b/Modules/FindCUDAToolkit.cmake index 06457d9..8afef5e 100644 --- a/Modules/FindCUDAToolkit.cmake +++ b/Modules/FindCUDAToolkit.cmake @@ -388,7 +388,6 @@ nvRTC """"" The `nvRTC <https://docs.nvidia.com/cuda/nvrtc/index.html>`_ (Runtime Compilation) library. -This is a shared library only. Targets Created: diff --git a/Modules/FindDoxygen.cmake b/Modules/FindDoxygen.cmake index ef9801e..76f4759 100644 --- a/Modules/FindDoxygen.cmake +++ b/Modules/FindDoxygen.cmake @@ -76,7 +76,8 @@ Functions [ALL] [USE_STAMP_FILE] [WORKING_DIRECTORY dir] - [COMMENT comment]) + [COMMENT comment] + [CONFIG_FILE filename]) The function constructs a ``Doxyfile`` and defines a custom target that runs Doxygen on that generated file. The listed files and directories are used as @@ -97,6 +98,10 @@ Functions the :command:`add_custom_target` command used to create the custom target internally. + .. versionadded:: 3.27 + If ``CONFIG_FILE`` is set, the given file provided with full-path + will be used as doxygen configuration file + .. versionadded:: 3.12 If ``ALL`` is set, the target will be added to the default build target. @@ -864,7 +869,7 @@ endfunction() function(doxygen_add_docs targetName) set(_options ALL USE_STAMP_FILE) - set(_one_value_args WORKING_DIRECTORY COMMENT) + set(_one_value_args WORKING_DIRECTORY COMMENT CONFIG_FILE) set(_multi_value_args) cmake_parse_arguments(_args "${_options}" @@ -1166,8 +1171,15 @@ doxygen_add_docs() for target ${targetName}") # Prepare doxygen configuration file set(_doxyfile_template "${CMAKE_BINARY_DIR}/CMakeDoxyfile.in") - set(_target_doxyfile "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile.${targetName}") - configure_file("${_doxyfile_template}" "${_target_doxyfile}") + if(_args_CONFIG_FILE) + if(NOT EXISTS "${_args_CONFIG_FILE}") + message(FATAL_ERROR "Option CONFIG_FILE specifies file:\n ${_args_CONFIG_FILE}\nbut it does not exist.") + endif() + set(_target_doxyfile "${_args_CONFIG_FILE}") + else() + set(_target_doxyfile "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile.${targetName}") + configure_file("${_doxyfile_template}" "${_target_doxyfile}") + endif() unset(_all) if(${_args_ALL}) diff --git a/Modules/FindJNI.cmake b/Modules/FindJNI.cmake index 64163b0..27f9b0e 100644 --- a/Modules/FindJNI.cmake +++ b/Modules/FindJNI.cmake @@ -290,6 +290,13 @@ set(_JNI_JAVA_DIRECTORIES_BASE # Arch Linux specific paths for default JVM /usr/lib/jvm/default # Ubuntu specific paths for default JVM + /usr/lib/jvm/java-21-openjdk-{libarch} # Ubuntu 23.04 + /usr/lib/jvm/java-20-openjdk-{libarch} # Ubuntu 22.10 + /usr/lib/jvm/java-19-openjdk-{libarch} # Ubuntu 22.04 LTS + /usr/lib/jvm/java-18-openjdk-{libarch} # Ubuntu 22.04 LTS + /usr/lib/jvm/java-17-openjdk-{libarch} # Ubuntu 18.04 LTS + /usr/lib/jvm/java-16-openjdk-{libarch} # Ubuntu 20.04 LTS + /usr/lib/jvm/java-13-openjdk-{libarch} # Ubuntu 20.04 LTS /usr/lib/jvm/java-11-openjdk-{libarch} # Ubuntu 18.04 LTS /usr/lib/jvm/java-8-openjdk-{libarch} # Ubuntu 15.10 /usr/lib/jvm/java-7-openjdk-{libarch} # Ubuntu 15.10 diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index 17117bd..4d3ab5a 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -561,6 +561,29 @@ if(NOT LAPACK_NOT_FOUND_MESSAGE) endif() endif() + # AOCL? (https://developer.amd.com/amd-aocl/) + if(NOT LAPACK_LIBRARIES + AND (BLA_VENDOR MATCHES "AOCL" OR BLA_VENDOR STREQUAL "All")) + if(_lapack_sizeof_integer EQUAL 8) + set(_lapack_aocl_subdir "ILP64") + else() + set(_lapack_aocl_subdir "LP64") + endif() + + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "flame" + "-fopenmp" + "" + "${_lapack_aocl_subdir}" + "${BLAS_LIBRARIES}" + ) + unset(_lapack_aocl_subdir) + endif() + # LAPACK in SCSL library? (SGI/Cray Scientific Library) if(NOT LAPACK_LIBRARIES AND (BLA_VENDOR MATCHES "SCSL" OR BLA_VENDOR STREQUAL "All")) diff --git a/Modules/FindX11.cmake b/Modules/FindX11.cmake index 6f6483a..1047e4f 100644 --- a/Modules/FindX11.cmake +++ b/Modules/FindX11.cmake @@ -22,55 +22,77 @@ and also the following more fine grained variables and targets: :: - X11_ICE_INCLUDE_PATH, X11_ICE_LIB, X11_ICE_FOUND, X11::ICE - X11_SM_INCLUDE_PATH, X11_SM_LIB, X11_SM_FOUND, X11::SM - X11_X11_INCLUDE_PATH, X11_X11_LIB, X11::X11 + X11_ICE_INCLUDE_PATH, X11_ICE_LIB, X11_ICE_FOUND, X11::ICE + X11_SM_INCLUDE_PATH, X11_SM_LIB, X11_SM_FOUND, X11::SM + X11_X11_INCLUDE_PATH, X11_X11_LIB, X11::X11 X11_Xaccessrules_INCLUDE_PATH, - X11_Xaccessstr_INCLUDE_PATH, X11_Xaccess_FOUND - X11_Xau_INCLUDE_PATH, X11_Xau_LIB, X11_Xau_FOUND, X11::Xau - X11_xcb_INCLUDE_PATH, X11_xcb_LIB, X11_xcb_FOUND, X11::xcb - X11_X11_xcb_INCLUDE_PATH, X11_X11_xcb_LIB, X11_X11_xcb_FOUND, X11::X11_xcb - X11_xcb_cursor_INCLUDE_PATH, X11_xcb_cursor_LIB, X11_xcb_cursor_FOUND, X11::xcb_cursor - X11_xcb_icccm_INCLUDE_PATH, X11_xcb_icccm_LIB, X11_xcb_icccm_FOUND, X11::xcb_icccm - X11_xcb_randr_INCLUDE_PATH, X11_xcb_randr_LIB, X11_xcb_randr_FOUND, X11::xcb_randr - X11_xcb_shape_INCLUDE_PATH, X11_xcb_shape_LIB, X11_xcb_shape_FOUND, X11::xcb_shape - X11_xcb_util_INCLUDE_PATH, X11_xcb_util_LIB, X11_xcb_util_FOUND, X11::xcb_util - X11_xcb_xfixes_INCLUDE_PATH, X11_xcb_xfixes_LIB, X11_xcb_xfixes_FOUND, X11::xcb_xfixes - X11_xcb_xrm_INCLUDE_PATH, X11_xcb_xrm_LIB, X11_xcb_xrm_FOUND, X11::xcb_xrm - X11_xcb_xtest_INCLUDE_PATH, X11_xcb_xtest_LIB, X11_xcb_xtest_FOUND, X11::xcb_xtest - X11_xcb_keysyms_INCLUDE_PATH, X11_xcb_keysyms_LIB,X11_xcb_keysyms_FOUND,X11::xcb_keysyms - X11_xcb_xkb_INCLUDE_PATH, X11_xcb_xkb_LIB, X11_xcb_xkb_FOUND, X11::xcb_xkb - X11_Xcomposite_INCLUDE_PATH, X11_Xcomposite_LIB, X11_Xcomposite_FOUND, X11::Xcomposite - X11_Xcursor_INCLUDE_PATH, X11_Xcursor_LIB, X11_Xcursor_FOUND, X11::Xcursor - X11_Xdamage_INCLUDE_PATH, X11_Xdamage_LIB, X11_Xdamage_FOUND, X11::Xdamage - X11_Xdmcp_INCLUDE_PATH, X11_Xdmcp_LIB, X11_Xdmcp_FOUND, X11::Xdmcp - X11_Xext_INCLUDE_PATH, X11_Xext_LIB, X11_Xext_FOUND, X11::Xext - X11_Xxf86misc_INCLUDE_PATH, X11_Xxf86misc_LIB, X11_Xxf86misc_FOUND, X11::Xxf86misc - X11_Xxf86vm_INCLUDE_PATH, X11_Xxf86vm_LIB X11_Xxf86vm_FOUND, X11::Xxf86vm - X11_Xfixes_INCLUDE_PATH, X11_Xfixes_LIB, X11_Xfixes_FOUND, X11::Xfixes - X11_Xft_INCLUDE_PATH, X11_Xft_LIB, X11_Xft_FOUND, X11::Xft - X11_Xi_INCLUDE_PATH, X11_Xi_LIB, X11_Xi_FOUND, X11::Xi - X11_Xinerama_INCLUDE_PATH, X11_Xinerama_LIB, X11_Xinerama_FOUND, X11::Xinerama + X11_Xaccessstr_INCLUDE_PATH, X11_Xaccess_FOUND + X11_Xau_INCLUDE_PATH, X11_Xau_LIB, X11_Xau_FOUND, X11::Xau + X11_xcb_INCLUDE_PATH, X11_xcb_LIB, X11_xcb_FOUND, X11::xcb + X11_X11_xcb_INCLUDE_PATH, X11_X11_xcb_LIB, X11_X11_xcb_FOUND, X11::X11_xcb + X11_xcb_composite_INCLUDE_PATH, X11_xcb_composite_LIB, X11_xcb_composite_FOUND, X11::xcb_composite + X11_xcb_cursor_INCLUDE_PATH, X11_xcb_cursor_LIB, X11_xcb_cursor_FOUND, X11::xcb_cursor + X11_xcb_damage_INCLUDE_PATH, X11_xcb_damage_LIB, X11_xcb_damage_FOUND, X11::xcb_damage + X11_xcb_dpms_INCLUDE_PATH, X11_xcb_dpms_LIB, X11_xcb_dpms_FOUND, X11::xcb_dpms + X11_xcb_dri2_INCLUDE_PATH, X11_xcb_dri2_LIB, X11_xcb_dri2_FOUND, X11::xcb_dri2 + X11_xcb_dri3_INCLUDE_PATH, X11_xcb_dri3_LIB, X11_xcb_dri3_FOUND, X11::xcb_dri3 + X11_xcb_errors_INCLUDE_PATH, X11_xcb_errors_LIB, X11_xcb_errors_FOUND, X11::xcb_errors + X11_xcb_ewmh_INCLUDE_PATH, X11_xcb_ewmh_LIB, X11_xcb_ewmh_FOUND, X11::xcb_ewmh + X11_xcb_glx_INCLUDE_PATH, X11_xcb_glx_LIB, X11_xcb_glx_FOUND, X11::xcb_glx + X11_xcb_icccm_INCLUDE_PATH, X11_xcb_icccm_LIB, X11_xcb_icccm_FOUND, X11::xcb_icccm + X11_xcb_image_INCLUDE_PATH, X11_xcb_image_LIB, X11_xcb_image_FOUND, X11::xcb_image + X11_xcb_keysyms_INCLUDE_PATH, X11_xcb_keysyms_LIB, X11_xcb_keysyms_FOUND, X11::xcb_keysyms + X11_xcb_present_INCLUDE_PATH, X11_xcb_present_LIB, X11_xcb_present_FOUND, X11::xcb_present + X11_xcb_randr_INCLUDE_PATH, X11_xcb_randr_LIB, X11_xcb_randr_FOUND, X11::xcb_randr + X11_xcb_record_INCLUDE_PATH, X11_xcb_record_LIB, X11_xcb_record_FOUND, X11::xcb_record + X11_xcb_render_INCLUDE_PATH, X11_xcb_render_LIB, X11_xcb_render_FOUND, X11::xcb_render + X11_xcb_render_util_INCLUDE_PATH,X11_xcb_render_util_LIB,X11_xcb_render_util_FOUND,X11::xcb_render_util + X11_xcb_res_INCLUDE_PATH, X11_xcb_res_LIB, X11_xcb_res_FOUND, X11::xcb_res + X11_xcb_screensaver_INCLUDE_PATH,X11_xcb_screensaver_LIB,X11_xcb_screensaver_FOUND,X11::xcb_screensaver + X11_xcb_shape_INCLUDE_PATH, X11_xcb_shape_LIB, X11_xcb_shape_FOUND, X11::xcb_shape + X11_xcb_shm_INCLUDE_PATH, X11_xcb_shm_LIB, X11_xcb_shm_FOUND, X11::xcb_shm + X11_xcb_sync_INCLUDE_PATH, X11_xcb_sync_LIB, X11_xcb_sync_FOUND, X11::xcb_sync + X11_xcb_util_INCLUDE_PATH, X11_xcb_util_LIB, X11_xcb_util_FOUND, X11::xcb_util + X11_xcb_xf86dri_INCLUDE_PATH, X11_xcb_xf86dri_LIB, X11_xcb_xf86dri_FOUND, X11::xcb_xf86dri + X11_xcb_xfixes_INCLUDE_PATH, X11_xcb_xfixes_LIB, X11_xcb_xfixes_FOUND, X11::xcb_xfixes + X11_xcb_xinerama_INCLUDE_PATH, X11_xcb_xinerama_LIB, X11_xcb_xinerama_FOUND, X11::xcb_xinerama + X11_xcb_xinput_INCLUDE_PATH, X11_xcb_xinput_LIB, X11_xcb_xinput_FOUND, X11::xcb_xinput + X11_xcb_xkb_INCLUDE_PATH, X11_xcb_xkb_LIB, X11_xcb_xkb_FOUND, X11::xcb_xkb + X11_xcb_xrm_INCLUDE_PATH, X11_xcb_xrm_LIB, X11_xcb_xrm_FOUND, X11::xcb_xrm + X11_xcb_xtest_INCLUDE_PATH, X11_xcb_xtest_LIB, X11_xcb_xtest_FOUND, X11::xcb_xtest + X11_xcb_xvmc_INCLUDE_PATH, X11_xcb_xvmc_LIB, X11_xcb_xvmc_FOUND, X11::xcb_xvmc + X11_xcb_xv_INCLUDE_PATH, X11_xcb_xv_LIB, X11_xcb_xv_FOUND X11::xcb_xv + X11_Xcomposite_INCLUDE_PATH, X11_Xcomposite_LIB, X11_Xcomposite_FOUND, X11::Xcomposite + X11_Xcursor_INCLUDE_PATH, X11_Xcursor_LIB, X11_Xcursor_FOUND, X11::Xcursor + X11_Xdamage_INCLUDE_PATH, X11_Xdamage_LIB, X11_Xdamage_FOUND, X11::Xdamage + X11_Xdmcp_INCLUDE_PATH, X11_Xdmcp_LIB, X11_Xdmcp_FOUND, X11::Xdmcp + X11_Xext_INCLUDE_PATH, X11_Xext_LIB, X11_Xext_FOUND, X11::Xext + X11_Xxf86misc_INCLUDE_PATH, X11_Xxf86misc_LIB, X11_Xxf86misc_FOUND, X11::Xxf86misc + X11_Xxf86vm_INCLUDE_PATH, X11_Xxf86vm_LIB X11_Xxf86vm_FOUND, X11::Xxf86vm + X11_Xfixes_INCLUDE_PATH, X11_Xfixes_LIB, X11_Xfixes_FOUND, X11::Xfixes + X11_Xft_INCLUDE_PATH, X11_Xft_LIB, X11_Xft_FOUND, X11::Xft + X11_Xi_INCLUDE_PATH, X11_Xi_LIB, X11_Xi_FOUND, X11::Xi + X11_Xinerama_INCLUDE_PATH, X11_Xinerama_LIB, X11_Xinerama_FOUND, X11::Xinerama X11_Xkb_INCLUDE_PATH, - X11_Xkblib_INCLUDE_PATH, X11_Xkb_FOUND, X11::Xkb - X11_xkbcommon_INCLUDE_PATH, X11_xkbcommon_LIB, X11_xkbcommon_FOUND, X11::xkbcommon - X11_xkbcommon_X11_INCLUDE_PATH,X11_xkbcommon_X11_LIB,X11_xkbcommon_X11_FOUND,X11::xkbcommon_X11 - X11_xkbfile_INCLUDE_PATH, X11_xkbfile_LIB, X11_xkbfile_FOUND, X11::xkbfile - X11_Xmu_INCLUDE_PATH, X11_Xmu_LIB, X11_Xmu_FOUND, X11::Xmu - X11_Xpm_INCLUDE_PATH, X11_Xpm_LIB, X11_Xpm_FOUND, X11::Xpm - X11_Xtst_INCLUDE_PATH, X11_Xtst_LIB, X11_Xtst_FOUND, X11::Xtst - X11_Xrandr_INCLUDE_PATH, X11_Xrandr_LIB, X11_Xrandr_FOUND, X11::Xrandr - X11_Xrender_INCLUDE_PATH, X11_Xrender_LIB, X11_Xrender_FOUND, X11::Xrender - X11_XRes_INCLUDE_PATH, X11_XRes_LIB, X11_XRes_FOUND, X11::XRes - X11_Xss_INCLUDE_PATH, X11_Xss_LIB, X11_Xss_FOUND, X11::Xss - X11_Xt_INCLUDE_PATH, X11_Xt_LIB, X11_Xt_FOUND, X11::Xt - X11_Xutil_INCLUDE_PATH, X11_Xutil_FOUND, X11::Xutil - X11_Xv_INCLUDE_PATH, X11_Xv_LIB, X11_Xv_FOUND, X11::Xv - X11_dpms_INCLUDE_PATH, (in X11_Xext_LIB), X11_dpms_FOUND - X11_XShm_INCLUDE_PATH, (in X11_Xext_LIB), X11_XShm_FOUND - X11_Xshape_INCLUDE_PATH, (in X11_Xext_LIB), X11_Xshape_FOUND - X11_XSync_INCLUDE_PATH, (in X11_Xext_LIB), X11_XSync_FOUND - X11_Xaw_INCLUDE_PATH, X11_Xaw_LIB X11_Xaw_FOUND X11::Xaw + X11_Xkblib_INCLUDE_PATH, X11_Xkb_FOUND, X11::Xkb + X11_xkbcommon_INCLUDE_PATH, X11_xkbcommon_LIB, X11_xkbcommon_FOUND, X11::xkbcommon + X11_xkbcommon_X11_INCLUDE_PATH, X11_xkbcommon_X11_LIB, X11_xkbcommon_X11_FOUND, X11::xkbcommon_X11 + X11_xkbfile_INCLUDE_PATH, X11_xkbfile_LIB, X11_xkbfile_FOUND, X11::xkbfile + X11_Xmu_INCLUDE_PATH, X11_Xmu_LIB, X11_Xmu_FOUND, X11::Xmu + X11_Xpm_INCLUDE_PATH, X11_Xpm_LIB, X11_Xpm_FOUND, X11::Xpm + X11_Xtst_INCLUDE_PATH, X11_Xtst_LIB, X11_Xtst_FOUND, X11::Xtst + X11_Xrandr_INCLUDE_PATH, X11_Xrandr_LIB, X11_Xrandr_FOUND, X11::Xrandr + X11_Xrender_INCLUDE_PATH, X11_Xrender_LIB, X11_Xrender_FOUND, X11::Xrender + X11_XRes_INCLUDE_PATH, X11_XRes_LIB, X11_XRes_FOUND, X11::XRes + X11_Xss_INCLUDE_PATH, X11_Xss_LIB, X11_Xss_FOUND, X11::Xss + X11_Xt_INCLUDE_PATH, X11_Xt_LIB, X11_Xt_FOUND, X11::Xt + X11_Xutil_INCLUDE_PATH, X11_Xutil_FOUND, X11::Xutil + X11_Xv_INCLUDE_PATH, X11_Xv_LIB, X11_Xv_FOUND, X11::Xv + X11_dpms_INCLUDE_PATH, (in X11_Xext_LIB), X11_dpms_FOUND + X11_XShm_INCLUDE_PATH, (in X11_Xext_LIB), X11_XShm_FOUND + X11_Xshape_INCLUDE_PATH, (in X11_Xext_LIB), X11_Xshape_FOUND + X11_XSync_INCLUDE_PATH, (in X11_Xext_LIB), X11_XSync_FOUND + X11_Xaw_INCLUDE_PATH, X11_Xaw_LIB X11_Xaw_FOUND X11::Xaw .. versionadded:: 3.14 Renamed ``Xxf86misc``, ``X11_Xxf86misc``, ``X11_Xxf86vm``, ``X11_xkbfile``, @@ -92,7 +114,12 @@ and also the following more fine grained variables and targets: Added the ``xcb_randr``, ``xcb_xtext``, and ``xcb_keysyms`` libraries. .. versionadded:: 3.27 - Added the ``xcb_cursor``, ``xcb_shape``, and ``xcb_xrm`` libraries. + Added the ``xcb_composite``, ``xcb_cursor``, ``xcb_damage``, ``xcb_dpms``, + ``xcb_dri2``, ``xcb_dri3``, ``xcb_errors``, ``xcb_ewmh``, ``xcb_glx``, + ``xcb_image``, ``xcb_present``, ``xcb_record``, ``xcb_render``, + ``xcb_render_util``, ``xcb_res``, ``xcb_screensaver``, ``xcb_shape``, + ``xcb_shm``, ``xcb_sync``, ``xcb_xf86dri``, ``xcb_xinerama``, ``xcb_xinput``, + ``xcb_xrm``, ``xcb_xvmc``, and ``xcb_xv`` libraries. #]=======================================================================] @@ -135,18 +162,41 @@ if (UNIX) find_path(X11_Xaccessrules_INCLUDE_PATH X11/extensions/XKBrules.h ${X11_INC_SEARCH_PATH}) find_path(X11_Xaccessstr_INCLUDE_PATH X11/extensions/XKBstr.h ${X11_INC_SEARCH_PATH}) find_path(X11_Xau_INCLUDE_PATH X11/Xauth.h ${X11_INC_SEARCH_PATH}) - find_path(X11_Xaw_INCLUDE_PATH X11/Xaw/Intrinsic.h ${X11_INC_SEARCH_PATH}) + find_path(X11_Xaw_INCLUDE_PATH X11/Xaw/Box.h ${X11_INC_SEARCH_PATH}) find_path(X11_xcb_INCLUDE_PATH xcb/xcb.h ${X11_INC_SEARCH_PATH}) find_path(X11_X11_xcb_INCLUDE_PATH X11/Xlib-xcb.h ${X11_INC_SEARCH_PATH}) + find_path(X11_xcb_composite_INCLUDE_PATH xcb/composite.h ${X11_INC_SEARCH_PATH}) find_path(X11_xcb_cursor_INCLUDE_PATH xcb/xcb_cursor.h ${X11_INC_SEARCH_PATH}) + find_path(X11_xcb_damage_INCLUDE_PATH xcb/damage.h ${X11_INC_SEARCH_PATH}) + find_path(X11_xcb_dpms_INCLUDE_PATH xcb/dpms.h ${X11_INC_SEARCH_PATH}) + find_path(X11_xcb_dri2_INCLUDE_PATH xcb/dri2.h ${X11_INC_SEARCH_PATH}) + find_path(X11_xcb_dri3_INCLUDE_PATH xcb/dri3.h ${X11_INC_SEARCH_PATH}) + find_path(X11_xcb_errors_INCLUDE_PATH xcb/xcb_errors.h ${X11_INC_SEARCH_PATH}) + find_path(X11_xcb_ewmh_INCLUDE_PATH xcb/xcb_ewmh.h ${X11_INC_SEARCH_PATH}) + find_path(X11_xcb_glx_INCLUDE_PATH xcb/glx.h ${X11_INC_SEARCH_PATH}) find_path(X11_xcb_icccm_INCLUDE_PATH xcb/xcb_icccm.h ${X11_INC_SEARCH_PATH}) + find_path(X11_xcb_image_INCLUDE_PATH xcb/xcb_image.h ${X11_INC_SEARCH_PATH}) + find_path(X11_xcb_keysyms_INCLUDE_PATH xcb/xcb_keysyms.h ${X11_INC_SEARCH_PATH}) + find_path(X11_xcb_present_INCLUDE_PATH xcb/present.h ${X11_INC_SEARCH_PATH}) find_path(X11_xcb_randr_INCLUDE_PATH xcb/randr.h ${X11_INC_SEARCH_PATH}) + find_path(X11_xcb_record_INCLUDE_PATH xcb/record.h ${X11_INC_SEARCH_PATH}) + find_path(X11_xcb_render_INCLUDE_PATH xcb/render.h ${X11_INC_SEARCH_PATH}) + find_path(X11_xcb_render_util_INCLUDE_PATH xcb/xcb_renderutil.h ${X11_INC_SEARCH_PATH}) + find_path(X11_xcb_res_INCLUDE_PATH xcb/res.h ${X11_INC_SEARCH_PATH}) + find_path(X11_xcb_screensaver_INCLUDE_PATH xcb/screensaver.h ${X11_INC_SEARCH_PATH}) find_path(X11_xcb_shape_INCLUDE_PATH xcb/shape.h ${X11_INC_SEARCH_PATH}) + find_path(X11_xcb_shm_INCLUDE_PATH xcb/shm.h ${X11_INC_SEARCH_PATH}) + find_path(X11_xcb_sync_INCLUDE_PATH xcb/sync.h ${X11_INC_SEARCH_PATH}) find_path(X11_xcb_util_INCLUDE_PATH xcb/xcb_aux.h ${X11_INC_SEARCH_PATH}) + find_path(X11_xcb_xf86dri_INCLUDE_PATH xcb/xf86dri.h ${X11_INC_SEARCH_PATH}) find_path(X11_xcb_xfixes_INCLUDE_PATH xcb/xfixes.h ${X11_INC_SEARCH_PATH}) + find_path(X11_xcb_xinerama_INCLUDE_PATH xcb/xinerama.h ${X11_INC_SEARCH_PATH}) + find_path(X11_xcb_xinput_INCLUDE_PATH xcb/xinput.h ${X11_INC_SEARCH_PATH}) + find_path(X11_xcb_xkb_INCLUDE_PATH xcb/xkb.h ${X11_INC_SEARCH_PATH}) find_path(X11_xcb_xrm_INCLUDE_PATH xcb/xcb_xrm.h ${X11_INC_SEARCH_PATH}) find_path(X11_xcb_xtest_INCLUDE_PATH xcb/xtest.h ${X11_INC_SEARCH_PATH}) - find_path(X11_xcb_keysyms_INCLUDE_PATH xcb/xcb_keysyms.h ${X11_INC_SEARCH_PATH}) + find_path(X11_xcb_xvmc_INCLUDE_PATH xcb/xvmc.h ${X11_INC_SEARCH_PATH}) + find_path(X11_xcb_xv_INCLUDE_PATH xcb/xv.h ${X11_INC_SEARCH_PATH}) find_path(X11_Xcomposite_INCLUDE_PATH X11/extensions/Xcomposite.h ${X11_INC_SEARCH_PATH}) find_path(X11_Xcursor_INCLUDE_PATH X11/Xcursor/Xcursor.h ${X11_INC_SEARCH_PATH}) find_path(X11_Xdamage_INCLUDE_PATH X11/extensions/Xdamage.h ${X11_INC_SEARCH_PATH}) @@ -191,45 +241,67 @@ if (UNIX) find_library(X11_X11_LIB X11 ${X11_LIB_SEARCH_PATH}) # Find additional X libraries. Keep list sorted by library name. - find_library(X11_ICE_LIB ICE ${X11_LIB_SEARCH_PATH}) - find_library(X11_SM_LIB SM ${X11_LIB_SEARCH_PATH}) - find_library(X11_Xau_LIB Xau ${X11_LIB_SEARCH_PATH}) - find_library(X11_Xaw_LIB Xaw ${X11_LIB_SEARCH_PATH}) - find_library(X11_xcb_LIB xcb ${X11_LIB_SEARCH_PATH}) - find_library(X11_X11_xcb_LIB X11-xcb ${X11_LIB_SEARCH_PATH}) - find_library(X11_xcb_cursor_LIB xcb-cursor ${X11_LIB_SEARCH_PATH}) - find_library(X11_xcb_icccm_LIB xcb-icccm ${X11_LIB_SEARCH_PATH}) - find_library(X11_xcb_randr_LIB xcb-randr ${X11_LIB_SEARCH_PATH}) - find_library(X11_xcb_shape_LIB xcb-shape ${X11_LIB_SEARCH_PATH}) - find_library(X11_xcb_util_LIB xcb-util ${X11_LIB_SEARCH_PATH}) - find_library(X11_xcb_xfixes_LIB xcb-xfixes ${X11_LIB_SEARCH_PATH}) - find_library(X11_xcb_xrm_LIB xcb-xrm ${X11_LIB_SEARCH_PATH}) - find_library(X11_xcb_xtest_LIB xcb-xtest ${X11_LIB_SEARCH_PATH}) - find_library(X11_xcb_keysyms_LIB xcb-keysyms ${X11_LIB_SEARCH_PATH}) - find_library(X11_xcb_xkb_LIB xcb-xkb ${X11_LIB_SEARCH_PATH}) - find_library(X11_Xcomposite_LIB Xcomposite ${X11_LIB_SEARCH_PATH}) - find_library(X11_Xcursor_LIB Xcursor ${X11_LIB_SEARCH_PATH}) - find_library(X11_Xdamage_LIB Xdamage ${X11_LIB_SEARCH_PATH}) - find_library(X11_Xdmcp_LIB Xdmcp ${X11_LIB_SEARCH_PATH}) - find_library(X11_Xext_LIB Xext ${X11_LIB_SEARCH_PATH}) - find_library(X11_Xfixes_LIB Xfixes ${X11_LIB_SEARCH_PATH}) - find_library(X11_Xft_LIB Xft ${X11_LIB_SEARCH_PATH}) - find_library(X11_Xi_LIB Xi ${X11_LIB_SEARCH_PATH}) - find_library(X11_Xinerama_LIB Xinerama ${X11_LIB_SEARCH_PATH}) - find_library(X11_xkbcommon_LIB xkbcommon ${X11_LIB_SEARCH_PATH}) - find_library(X11_xkbcommon_X11_LIB xkbcommon-x11 ${X11_LIB_SEARCH_PATH}) - find_library(X11_xkbfile_LIB xkbfile ${X11_LIB_SEARCH_PATH}) - find_library(X11_Xmu_LIB Xmu ${X11_LIB_SEARCH_PATH}) - find_library(X11_Xpm_LIB Xpm ${X11_LIB_SEARCH_PATH}) - find_library(X11_Xrandr_LIB Xrandr ${X11_LIB_SEARCH_PATH}) - find_library(X11_Xrender_LIB Xrender ${X11_LIB_SEARCH_PATH}) - find_library(X11_XRes_LIB XRes ${X11_LIB_SEARCH_PATH}) - find_library(X11_Xss_LIB Xss ${X11_LIB_SEARCH_PATH}) - find_library(X11_Xt_LIB Xt ${X11_LIB_SEARCH_PATH}) - find_library(X11_Xtst_LIB Xtst ${X11_LIB_SEARCH_PATH}) - find_library(X11_Xv_LIB Xv ${X11_LIB_SEARCH_PATH}) - find_library(X11_Xxf86misc_LIB Xxf86misc ${X11_LIB_SEARCH_PATH}) - find_library(X11_Xxf86vm_LIB Xxf86vm ${X11_LIB_SEARCH_PATH}) + find_library(X11_ICE_LIB ICE ${X11_LIB_SEARCH_PATH}) + find_library(X11_SM_LIB SM ${X11_LIB_SEARCH_PATH}) + find_library(X11_Xau_LIB Xau ${X11_LIB_SEARCH_PATH}) + find_library(X11_Xaw_LIB Xaw ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_LIB xcb ${X11_LIB_SEARCH_PATH}) + find_library(X11_X11_xcb_LIB X11-xcb ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_composite_LIB xcb-composite ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_cursor_LIB xcb-cursor ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_damage_LIB xcb-damage ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_dpms_LIB xcb-dpms ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_dri2_LIB xcb-dri2 ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_dri3_LIB xcb-dri3 ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_errors_LIB xcb-errors ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_ewmh_LIB xcb-ewmh ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_glx_LIB xcb-glx ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_icccm_LIB xcb-icccm ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_image_LIB xcb-image ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_keysyms_LIB xcb-keysyms ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_present_LIB xcb-present ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_randr_LIB xcb-randr ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_record_LIB xcb-record ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_render_LIB xcb-render ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_render_util_LIB xcb-render-util ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_res_LIB xcb-res ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_screensaver_LIB xcb-screensaver ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_shape_LIB xcb-shape ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_shm_LIB xcb-shm ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_sync_LIB xcb-sync ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_util_LIB xcb-util ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_xf86dri_LIB xcb-xf86dri ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_xfixes_LIB xcb-xfixes ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_xinerama_LIB xcb-xinerama ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_xinput_LIB xcb-xinput ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_xkb_LIB xcb-xkb ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_xrm_LIB xcb-xrm ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_xtest_LIB xcb-xtest ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_xvmc_LIB xcb-xvmc ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_xv_LIB xcb-xv ${X11_LIB_SEARCH_PATH}) + find_library(X11_Xcomposite_LIB Xcomposite ${X11_LIB_SEARCH_PATH}) + find_library(X11_Xcursor_LIB Xcursor ${X11_LIB_SEARCH_PATH}) + find_library(X11_Xdamage_LIB Xdamage ${X11_LIB_SEARCH_PATH}) + find_library(X11_Xdmcp_LIB Xdmcp ${X11_LIB_SEARCH_PATH}) + find_library(X11_Xext_LIB Xext ${X11_LIB_SEARCH_PATH}) + find_library(X11_Xfixes_LIB Xfixes ${X11_LIB_SEARCH_PATH}) + find_library(X11_Xft_LIB Xft ${X11_LIB_SEARCH_PATH}) + find_library(X11_Xi_LIB Xi ${X11_LIB_SEARCH_PATH}) + find_library(X11_Xinerama_LIB Xinerama ${X11_LIB_SEARCH_PATH}) + find_library(X11_xkbcommon_LIB xkbcommon ${X11_LIB_SEARCH_PATH}) + find_library(X11_xkbcommon_X11_LIB xkbcommon-x11 ${X11_LIB_SEARCH_PATH}) + find_library(X11_xkbfile_LIB xkbfile ${X11_LIB_SEARCH_PATH}) + find_library(X11_Xmu_LIB Xmu ${X11_LIB_SEARCH_PATH}) + find_library(X11_Xpm_LIB Xpm ${X11_LIB_SEARCH_PATH}) + find_library(X11_Xrandr_LIB Xrandr ${X11_LIB_SEARCH_PATH}) + find_library(X11_Xrender_LIB Xrender ${X11_LIB_SEARCH_PATH}) + find_library(X11_XRes_LIB XRes ${X11_LIB_SEARCH_PATH}) + find_library(X11_Xss_LIB Xss ${X11_LIB_SEARCH_PATH}) + find_library(X11_Xt_LIB Xt ${X11_LIB_SEARCH_PATH}) + find_library(X11_Xtst_LIB Xtst ${X11_LIB_SEARCH_PATH}) + find_library(X11_Xv_LIB Xv ${X11_LIB_SEARCH_PATH}) + find_library(X11_Xxf86misc_LIB Xxf86misc ${X11_LIB_SEARCH_PATH}) + find_library(X11_Xxf86vm_LIB Xxf86vm ${X11_LIB_SEARCH_PATH}) # Backwards compatibility. set(X11_Xinput_LIB "${X11_Xi_LIB}") @@ -301,44 +373,132 @@ if (UNIX) set(X11_X11_xcb_FOUND TRUE) endif () + if (X11_xcb_composite_LIB AND X11_xcb_composite_INCLUDE_PATH) + set(X11_xcb_composite_FOUND TRUE) + endif () + if (X11_xcb_cursor_LIB AND X11_xcb_cursor_INCLUDE_PATH) set(X11_xcb_cursor_FOUND TRUE) endif () + if (X11_xcb_damage_LIB AND X11_xcb_damage_INCLUDE_PATH) + set(X11_xcb_damage_FOUND TRUE) + endif () + + if (X11_xcb_dpms_LIB AND X11_xcb_dpms_INCLUDE_PATH) + set(X11_xcb_dpms_FOUND TRUE) + endif () + + if (X11_xcb_dri2_LIB AND X11_xcb_dri2_INCLUDE_PATH) + set(X11_xcb_dri2_FOUND TRUE) + endif () + + if (X11_xcb_dri3_LIB AND X11_xcb_dri3_INCLUDE_PATH) + set(X11_xcb_dri3_FOUND TRUE) + endif () + + if (X11_xcb_errors_LIB AND X11_xcb_errors_INCLUDE_PATH) + set(X11_xcb_errors_FOUND TRUE) + endif () + + if (X11_xcb_ewmh_LIB AND X11_xcb_ewmh_INCLUDE_PATH) + set(X11_xcb_ewmh_FOUND TRUE) + endif () + + if (X11_xcb_glx_LIB AND X11_xcb_glx_INCLUDE_PATH) + set(X11_xcb_glx_FOUND TRUE) + endif () + if (X11_xcb_icccm_LIB AND X11_xcb_icccm_INCLUDE_PATH) set(X11_xcb_icccm_FOUND TRUE) endif () + if (X11_xcb_image_LIB AND X11_xcb_image_INCLUDE_PATH) + set(X11_xcb_image_FOUND TRUE) + endif () + + if (X11_xcb_keysyms_LIB AND X11_xcb_keysyms_INCLUDE_PATH) + set(X11_xcb_keysyms_FOUND TRUE) + endif () + + if (X11_xcb_present_LIB AND X11_xcb_present_INCLUDE_PATH) + set(X11_xcb_present_FOUND TRUE) + endif () + if (X11_xcb_randr_LIB AND X11_xcb_randr_INCLUDE_PATH) set(X11_xcb_randr_FOUND TRUE) endif () + if (X11_xcb_record_LIB AND X11_xcb_record_INCLUDE_PATH) + set(X11_xcb_record_FOUND TRUE) + endif () + + if (X11_xcb_render_LIB AND X11_xcb_render_INCLUDE_PATH) + set(X11_xcb_render_FOUND TRUE) + endif () + + if (X11_xcb_render_util_LIB AND X11_xcb_render_util_INCLUDE_PATH) + set(X11_xcb_render_util_FOUND TRUE) + endif () + + if (X11_xcb_res_LIB AND X11_xcb_res_INCLUDE_PATH) + set(X11_xcb_res_FOUND TRUE) + endif () + + if (X11_xcb_screensaver_LIB AND X11_xcb_screensaver_INCLUDE_PATH) + set(X11_xcb_screensaver_FOUND TRUE) + endif () + if (X11_xcb_shape_LIB AND X11_xcb_shape_INCLUDE_PATH) set(X11_xcb_shape_FOUND TRUE) endif () + if (X11_xcb_shm_LIB AND X11_xcb_shm_INCLUDE_PATH) + set(X11_xcb_shm_FOUND TRUE) + endif () + + if (X11_xcb_sync_LIB AND X11_xcb_sync_INCLUDE_PATH) + set(X11_xcb_sync_FOUND TRUE) + endif () + if (X11_xcb_util_LIB AND X11_xcb_util_INCLUDE_PATH) set(X11_xcb_util_FOUND TRUE) endif () - if (X11_xcb_xfixes_LIB) + if (X11_xcb_xf86dri_LIB AND X11_xcb_xf86dri_INCLUDE_PATH) + set(X11_xcb_xf86dri_FOUND TRUE) + endif () + + if (X11_xcb_xfixes_LIB AND X11_xcb_xfixes_INCLUDE_PATH) set(X11_xcb_xfixes_FOUND TRUE) endif () + if (X11_xcb_xinerama_LIB AND X11_xcb_xinerama_INCLUDE_PATH) + set(X11_xcb_xinerama_FOUND TRUE) + endif () + + if (X11_xcb_xinput_LIB AND X11_xcb_xinput_INCLUDE_PATH) + set(X11_xcb_xinput_FOUND TRUE) + endif () + + if (X11_xcb_xkb_LIB AND X11_xcb_xkb_INCLUDE_PATH) + set(X11_xcb_xkb_FOUND TRUE) + endif () + if (X11_xcb_xrm_LIB AND X11_xcb_xrm_INCLUDE_PATH) set(X11_xcb_xrm_FOUND TRUE) endif () - if (X11_xcb_xtest_LIB) + if (X11_xcb_xtest_LIB AND X11_xcb_xtest_INCLUDE_PATH) set(X11_xcb_xtest_FOUND TRUE) endif () - if (X11_xcb_keysyms_LIB) - set(X11_xcb_keysyms_FOUND TRUE) + if (X11_xcb_xvmc_LIB AND X11_xcb_xvmc_INCLUDE_PATH) + set(X11_xcb_xvmc_FOUND TRUE) endif () - if (X11_xcb_xkb_LIB) - set(X11_xcb_xkb_FOUND TRUE) + if (X11_xcb_xv_LIB AND X11_xcb_xv_INCLUDE_PATH) + set(X11_xcb_xv_FOUND TRUE) endif () if (X11_Xdmcp_INCLUDE_PATH AND X11_Xdmcp_LIB) @@ -641,6 +801,13 @@ if (UNIX) INTERFACE_LINK_LIBRARIES "X11::xcb;X11::X11") endif () + if (X11_xcb_composite_FOUND AND NOT TARGET X11::xcb_composite) + add_library(X11::xcb_composite UNKNOWN IMPORTED) + set_target_properties(X11::xcb_composite PROPERTIES + IMPORTED_LOCATION "${X11_xcb_composite_LIB}" + INTERFACE_LINK_LIBRARIES "X11::xcb") + endif () + if (X11_xcb_cursor_FOUND AND NOT TARGET X11::xcb_cursor) add_library(X11::xcb_cursor UNKNOWN IMPORTED) set_target_properties(X11::xcb_cursor PROPERTIES @@ -648,6 +815,55 @@ if (UNIX) INTERFACE_LINK_LIBRARIES "X11::xcb") endif () + if (X11_xcb_damage_FOUND AND NOT TARGET X11::xcb_damage) + add_library(X11::xcb_damage UNKNOWN IMPORTED) + set_target_properties(X11::xcb_damage PROPERTIES + IMPORTED_LOCATION "${X11_xcb_damage_LIB}" + INTERFACE_LINK_LIBRARIES "X11::xcb") + endif () + + if (X11_xcb_dpms_FOUND AND NOT TARGET X11::xcb_dpms) + add_library(X11::xcb_dpms UNKNOWN IMPORTED) + set_target_properties(X11::xcb_dpms PROPERTIES + IMPORTED_LOCATION "${X11_xcb_dpms_LIB}" + INTERFACE_LINK_LIBRARIES "X11::xcb") + endif () + + if (X11_xcb_dri2_FOUND AND NOT TARGET X11::xcb_dri2) + add_library(X11::xcb_dri2 UNKNOWN IMPORTED) + set_target_properties(X11::xcb_dri2 PROPERTIES + IMPORTED_LOCATION "${X11_xcb_dri2_LIB}" + INTERFACE_LINK_LIBRARIES "X11::xcb") + endif () + + if (X11_xcb_dri3_FOUND AND NOT TARGET X11::xcb_dri3) + add_library(X11::xcb_dri3 UNKNOWN IMPORTED) + set_target_properties(X11::xcb_dri3 PROPERTIES + IMPORTED_LOCATION "${X11_xcb_dri3_LIB}" + INTERFACE_LINK_LIBRARIES "X11::xcb") + endif () + + if (X11_xcb_errors_FOUND AND NOT TARGET X11::xcb_errors) + add_library(X11::xcb_errors UNKNOWN IMPORTED) + set_target_properties(X11::xcb_errors PROPERTIES + IMPORTED_LOCATION "${X11_xcb_errors_LIB}" + INTERFACE_LINK_LIBRARIES "X11::xcb") + endif () + + if (X11_xcb_ewmh_FOUND AND NOT TARGET X11::xcb_ewmh) + add_library(X11::xcb_ewmh UNKNOWN IMPORTED) + set_target_properties(X11::xcb_ewmh PROPERTIES + IMPORTED_LOCATION "${X11_xcb_ewmh_LIB}" + INTERFACE_LINK_LIBRARIES "X11::xcb") + endif () + + if (X11_xcb_glx_FOUND AND NOT TARGET X11::xcb_glx) + add_library(X11::xcb_glx UNKNOWN IMPORTED) + set_target_properties(X11::xcb_glx PROPERTIES + IMPORTED_LOCATION "${X11_xcb_glx_LIB}" + INTERFACE_LINK_LIBRARIES "X11::xcb") + endif () + if (X11_xcb_icccm_FOUND AND NOT TARGET X11::xcb_icccm) add_library(X11::xcb_icccm UNKNOWN IMPORTED) set_target_properties(X11::xcb_icccm PROPERTIES @@ -655,6 +871,27 @@ if (UNIX) INTERFACE_LINK_LIBRARIES "X11::xcb") endif () + if (X11_xcb_image_FOUND AND NOT TARGET X11::xcb_image) + add_library(X11::xcb_image UNKNOWN IMPORTED) + set_target_properties(X11::xcb_image PROPERTIES + IMPORTED_LOCATION "${X11_xcb_image_LIB}" + INTERFACE_LINK_LIBRARIES "X11::xcb") + endif () + + if (X11_xcb_keysyms_FOUND AND NOT TARGET X11::xcb_keysyms) + add_library(X11::xcb_keysyms UNKNOWN IMPORTED) + set_target_properties(X11::xcb_keysyms PROPERTIES + IMPORTED_LOCATION "${X11_xcb_keysyms_LIB}" + INTERFACE_LINK_LIBRARIES "X11::xcb") + endif () + + if (X11_xcb_present_FOUND AND NOT TARGET X11::xcb_present) + add_library(X11::xcb_present UNKNOWN IMPORTED) + set_target_properties(X11::xcb_present PROPERTIES + IMPORTED_LOCATION "${X11_xcb_present_LIB}" + INTERFACE_LINK_LIBRARIES "X11::xcb") + endif () + if (X11_xcb_randr_FOUND AND NOT TARGET X11::xcb_randr) add_library(X11::xcb_randr UNKNOWN IMPORTED) set_target_properties(X11::xcb_randr PROPERTIES @@ -662,6 +899,41 @@ if (UNIX) INTERFACE_LINK_LIBRARIES "X11::xcb") endif () + if (X11_xcb_record_FOUND AND NOT TARGET X11::xcb_record) + add_library(X11::xcb_record UNKNOWN IMPORTED) + set_target_properties(X11::xcb_record PROPERTIES + IMPORTED_LOCATION "${X11_xcb_record_LIB}" + INTERFACE_LINK_LIBRARIES "X11::xcb") + endif () + + if (X11_xcb_render_FOUND AND NOT TARGET X11::xcb_render) + add_library(X11::xcb_render UNKNOWN IMPORTED) + set_target_properties(X11::xcb_render PROPERTIES + IMPORTED_LOCATION "${X11_xcb_render_LIB}" + INTERFACE_LINK_LIBRARIES "X11::xcb") + endif () + + if (X11_xcb_render_util_FOUND AND NOT TARGET X11::xcb_render_util) + add_library(X11::xcb_render_util UNKNOWN IMPORTED) + set_target_properties(X11::xcb_render_util PROPERTIES + IMPORTED_LOCATION "${X11_xcb_render_util_LIB}" + INTERFACE_LINK_LIBRARIES "X11::xcb") + endif () + + if (X11_xcb_res_FOUND AND NOT TARGET X11::xcb_res) + add_library(X11::xcb_res UNKNOWN IMPORTED) + set_target_properties(X11::xcb_res PROPERTIES + IMPORTED_LOCATION "${X11_xcb_res_LIB}" + INTERFACE_LINK_LIBRARIES "X11::xcb") + endif () + + if (X11_xcb_screensaver_FOUND AND NOT TARGET X11::xcb_screensaver) + add_library(X11::xcb_screensaver UNKNOWN IMPORTED) + set_target_properties(X11::xcb_screensaver PROPERTIES + IMPORTED_LOCATION "${X11_xcb_screensaver_LIB}" + INTERFACE_LINK_LIBRARIES "X11::xcb") + endif () + if (X11_xcb_shape_FOUND AND NOT TARGET X11::xcb_shape) add_library(X11::xcb_shape UNKNOWN IMPORTED) set_target_properties(X11::xcb_shape PROPERTIES @@ -669,6 +941,20 @@ if (UNIX) INTERFACE_LINK_LIBRARIES "X11::xcb") endif () + if (X11_xcb_shm_FOUND AND NOT TARGET X11::xcb_shm) + add_library(X11::xcb_shm UNKNOWN IMPORTED) + set_target_properties(X11::xcb_shm PROPERTIES + IMPORTED_LOCATION "${X11_xcb_shm_LIB}" + INTERFACE_LINK_LIBRARIES "X11::xcb") + endif () + + if (X11_xcb_sync_FOUND AND NOT TARGET X11::xcb_sync) + add_library(X11::xcb_sync UNKNOWN IMPORTED) + set_target_properties(X11::xcb_sync PROPERTIES + IMPORTED_LOCATION "${X11_xcb_sync_LIB}" + INTERFACE_LINK_LIBRARIES "X11::xcb") + endif () + if (X11_xcb_util_FOUND AND NOT TARGET X11::xcb_util) add_library(X11::xcb_util UNKNOWN IMPORTED) set_target_properties(X11::xcb_util PROPERTIES @@ -676,6 +962,13 @@ if (UNIX) INTERFACE_LINK_LIBRARIES "X11::xcb") endif () + if (X11_xcb_xf86dri_FOUND AND NOT TARGET X11::xcb_xf86dri) + add_library(X11::xcb_xf86dri UNKNOWN IMPORTED) + set_target_properties(X11::xcb_xf86dri PROPERTIES + IMPORTED_LOCATION "${X11_xcb_xf86dri_LIB}" + INTERFACE_LINK_LIBRARIES "X11::xcb") + endif () + if (X11_xcb_xfixes_FOUND AND NOT TARGET X11::xcb_xfixes) add_library(X11::xcb_xfixes UNKNOWN IMPORTED) set_target_properties(X11::xcb_xfixes PROPERTIES @@ -683,6 +976,27 @@ if (UNIX) INTERFACE_LINK_LIBRARIES "X11::xcb") endif () + if (X11_xcb_xinerama_FOUND AND NOT TARGET X11::xcb_xinerama) + add_library(X11::xcb_xinerama UNKNOWN IMPORTED) + set_target_properties(X11::xcb_xinerama PROPERTIES + IMPORTED_LOCATION "${X11_xcb_xinerama_LIB}" + INTERFACE_LINK_LIBRARIES "X11::xcb") + endif () + + if (X11_xcb_xinput_FOUND AND NOT TARGET X11::xcb_xinput) + add_library(X11::xcb_xinput UNKNOWN IMPORTED) + set_target_properties(X11::xcb_xinput PROPERTIES + IMPORTED_LOCATION "${X11_xcb_xinput_LIB}" + INTERFACE_LINK_LIBRARIES "X11::xcb") + endif () + + if (X11_xcb_xkb_FOUND AND NOT TARGET X11::xcb_xkb) + add_library(X11::xcb_xkb UNKNOWN IMPORTED) + set_target_properties(X11::xcb_xkb PROPERTIES + IMPORTED_LOCATION "${X11_xcb_xkb_LIB}" + INTERFACE_LINK_LIBRARIES "X11::xcb") + endif () + if (X11_xcb_xrm_FOUND AND NOT TARGET X11::xcb_xrm) add_library(X11::xcb_xrm UNKNOWN IMPORTED) set_target_properties(X11::xcb_xrm PROPERTIES @@ -697,17 +1011,17 @@ if (UNIX) INTERFACE_LINK_LIBRARIES "X11::xcb") endif () - if (X11_xcb_keysyms_FOUND AND NOT TARGET X11::xcb_keysyms) - add_library(X11::xcb_keysyms UNKNOWN IMPORTED) - set_target_properties(X11::xcb_keysyms PROPERTIES - IMPORTED_LOCATION "${X11_xcb_keysyms_LIB}" + if (X11_xcb_xvmc_FOUND AND NOT TARGET X11::xcb_xvmc) + add_library(X11::xcb_xvmc UNKNOWN IMPORTED) + set_target_properties(X11::xcb_xvmc PROPERTIES + IMPORTED_LOCATION "${X11_xcb_xvmc_LIB}" INTERFACE_LINK_LIBRARIES "X11::xcb") endif () - if (X11_xcb_xkb_FOUND AND NOT TARGET X11::xcb_xkb) - add_library(X11::xcb_xkb UNKNOWN IMPORTED) - set_target_properties(X11::xcb_xkb PROPERTIES - IMPORTED_LOCATION "${X11_xcb_xkb_LIB}" + if (X11_xcb_xv_FOUND AND NOT TARGET X11::xcb_xv) + add_library(X11::xcb_xv UNKNOWN IMPORTED) + set_target_properties(X11::xcb_xv PROPERTIES + IMPORTED_LOCATION "${X11_xcb_xv_LIB}" INTERFACE_LINK_LIBRARIES "X11::xcb") endif () @@ -918,26 +1232,70 @@ if (UNIX) X11_Xau_INCLUDE_PATH X11_xcb_LIB X11_xcb_INCLUDE_PATH + X11_xcb_composite_LIB + X11_xcb_composite_INCLUDE_PATH X11_xcb_cursor_LIB X11_xcb_cursor_INCLUDE_PATH + X11_xcb_damage_LIB + X11_xcb_damage_INCLUDE_PATH + X11_xcb_dpms_LIB + X11_xcb_dpms_INCLUDE_PATH + X11_xcb_dri2_LIB + X11_xcb_dri2_INCLUDE_PATH + X11_xcb_dri3_LIB + X11_xcb_dri3_INCLUDE_PATH + X11_xcb_errors_LIB + X11_xcb_errors_INCLUDE_PATH + X11_xcb_ewmh_LIB + X11_xcb_ewmh_INCLUDE_PATH + X11_xcb_glx_LIB + X11_xcb_glx_INCLUDE_PATH X11_xcb_icccm_LIB X11_xcb_icccm_INCLUDE_PATH + X11_xcb_image_LIB + X11_xcb_image_INCLUDE_PATH + X11_xcb_keysyms_LIB + X11_xcb_keysyms_INCLUDE_PATH + X11_xcb_present_LIB + X11_xcb_present_INCLUDE_PATH X11_xcb_randr_LIB X11_xcb_randr_INCLUDE_PATH + X11_xcb_record_LIB + X11_xcb_record_INCLUDE_PATH + X11_xcb_render_LIB + X11_xcb_render_INCLUDE_PATH + X11_xcb_render_util_LIB + X11_xcb_render_util_INCLUDE_PATH + X11_xcb_res_LIB + X11_xcb_res_INCLUDE_PATH + X11_xcb_screensaver_LIB + X11_xcb_screensaver_INCLUDE_PATH X11_xcb_shape_LIB X11_xcb_shape_INCLUDE_PATH + X11_xcb_shm_LIB + X11_xcb_shm_INCLUDE_PATH + X11_xcb_sync_LIB + X11_xcb_sync_INCLUDE_PATH X11_xcb_util_LIB X11_xcb_util_INCLUDE_PATH + X11_xcb_xf86dri_LIB + X11_xcb_xf86dri_INCLUDE_PATH X11_xcb_xfixes_LIB X11_xcb_xfixes_INCLUDE_PATH + X11_xcb_xinerama_LIB + X11_xcb_xinerama_INCLUDE_PATH + X11_xcb_xinput_LIB + X11_xcb_xinput_INCLUDE_PATH + X11_xcb_xkb_LIB + X11_X11_xcb_LIB X11_xcb_xrm_LIB X11_xcb_xrm_INCLUDE_PATH X11_xcb_xtest_LIB X11_xcb_xtest_INCLUDE_PATH - X11_xcb_keysyms_LIB - X11_xcb_keysyms_INCLUDE_PATH - X11_xcb_xkb_LIB - X11_X11_xcb_LIB + X11_xcb_xvmc_LIB + X11_xcb_xvmc_INCLUDE_PATH + X11_xcb_xv_LIB + X11_xcb_xv_INCLUDE_PATH X11_X11_xcb_INCLUDE_PATH X11_Xlib_INCLUDE_PATH X11_Xutil_INCLUDE_PATH diff --git a/Modules/FortranCInterface.cmake b/Modules/FortranCInterface.cmake index ed8830e..2c85029 100644 --- a/Modules/FortranCInterface.cmake +++ b/Modules/FortranCInterface.cmake @@ -373,6 +373,7 @@ function(FortranCInterface_VERIFY) "-DCMAKE_C_FLAGS_RELEASE:STRING=${CMAKE_C_FLAGS_RELEASE}" "-DCMAKE_CXX_FLAGS_RELEASE:STRING=${CMAKE_CXX_FLAGS_RELEASE}" "-DCMAKE_Fortran_FLAGS_RELEASE:STRING=${CMAKE_Fortran_FLAGS_RELEASE}" + "-DFortranCInterface_BINARY_DIR=${FortranCInterface_BINARY_DIR}" ${_FortranCInterface_OSX_ARCH} ${_FortranCInterface_EXE_LINKER_FLAGS} OUTPUT_VARIABLE _output) diff --git a/Modules/Internal/CPack/ISComponents.pas b/Modules/Internal/CPack/ISComponents.pas new file mode 100644 index 0000000..8b5c8b4 --- /dev/null +++ b/Modules/Internal/CPack/ISComponents.pas @@ -0,0 +1,88 @@ +{ Distributed under the OSI-approved BSD 3-Clause License. See accompanying +file Copyright.txt or https://cmake.org/licensing for details. } + +function CPackGetCustomInstallationMessage(Param: String): String; +begin + Result := SetupMessage(msgCustomInstallation); +end; + +{ Downloaded components } +#ifdef CPackDownloadCount +const + NO_PROGRESS_BOX = 4; + RESPOND_YES_TO_ALL = 16; +var + CPackDownloadPage: TDownloadWizardPage; + CPackShell: Variant; + +<event('InitializeWizard')> +procedure CPackInitializeWizard(); +begin + CPackDownloadPage := CreateDownloadPage(SetupMessage(msgWizardPreparing), SetupMessage(msgPreparingDesc), nil); + CPackShell := CreateOleObject('Shell.Application'); +end; + +<event('NextButtonClick')> +function CPackNextButtonClick(CurPageID: Integer): Boolean; +begin + if CurPageID = wpReady then + begin + CPackDownloadPage.Clear; + CPackDownloadPage.Show; + +#sub AddDownload + if WizardIsComponentSelected('{#CPackDownloadComponents[i]}') then + #emit "CPackDownloadPage.Add('" + CPackDownloadUrls[i] + "', '" + CPackDownloadArchives[i] + ".zip', '" + CPackDownloadHashes[i] + "');" +#endsub +#define i +#for {i = 0; i < CPackDownloadCount; i++} AddDownload +#undef i + + try + try + CPackDownloadPage.Download; + Result := True; + except + if not CPackDownloadPage.AbortedByUser then + SuppressibleMsgBox(AddPeriod(GetExceptionMessage), mbCriticalError, MB_OK, IDOK); + + Result := False; + end; + finally + CPackDownloadPage.Hide; + end; + end else + Result := True; +end; + +procedure CPackExtractFile(ArchiveName, FileName: String); +var + ZipFileName: String; + ZipFile: Variant; + Item: Variant; + TargetFolderName: String; + TargetFolder: Variant; +begin + TargetFolderName := RemoveBackslashUnlessRoot(ExpandConstant('{tmp}\' + ArchiveName + '\' + ExtractFileDir(FileName))); + ZipFileName := ExpandConstant('{tmp}\' + ArchiveName + '.zip'); + + if not DirExists(TargetFolderName) then + if not ForceDirectories(TargetFolderName) then + RaiseException(Format('Target path "%s" cannot be created', [TargetFolderName])); + + ZipFile := CPackShell.NameSpace(ZipFileName); + if VarIsClear(ZipFile) then + RaiseException(Format('Cannot open ZIP file "%s" or does not exist', [ZipFileName])); + + Item := ZipFile.ParseName(FileName); + if VarIsClear(Item) then + RaiseException(Format('Cannot find "%s" in "%s" ZIP file', [FileName, ZipFileName])); + + TargetFolder := CPackShell.NameSpace(TargetFolderName); + if VarIsClear(TargetFolder) then + RaiseException(Format('Target path "%s" does not exist', [TargetFolderName])); + + TargetFolder.CopyHere(Item, NO_PROGRESS_BOX or RESPOND_YES_TO_ALL); +end; + +#endif diff --git a/Modules/Internal/CPack/ISScript.template.in b/Modules/Internal/CPack/ISScript.template.in new file mode 100644 index 0000000..1171058 --- /dev/null +++ b/Modules/Internal/CPack/ISScript.template.in @@ -0,0 +1,34 @@ +; Script generated by the CPack Inno Setup generator. +; All changes made in this file will be lost when CPack is run again. + +@CPACK_INNOSETUP_INCLUDES_INTERNAL@ + +[Setup] +@CPACK_INNOSETUP_SETUP_INTERNAL@ + +[Languages] +@CPACK_INNOSETUP_LANGUAGES_INTERNAL@ + +[Dirs] +@CPACK_INNOSETUP_DIRS_INTERNAL@ + +[Files] +@CPACK_INNOSETUP_FILES_INTERNAL@ + +[Types] +@CPACK_INNOSETUP_TYPES_INTERNAL@ + +[Components] +@CPACK_INNOSETUP_COMPONENTS_INTERNAL@ + +[Tasks] +@CPACK_INNOSETUP_TASKS_INTERNAL@ + +[Icons] +@CPACK_INNOSETUP_ICONS_INTERNAL@ + +[Run] +@CPACK_INNOSETUP_RUN_INTERNAL@ + +[Code] +@CPACK_INNOSETUP_CODE_INTERNAL@ diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 4a7d9bc..2354f3d 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -1018,6 +1018,7 @@ add_library( CPack/cmCPackGeneratorFactory.cxx CPack/cmCPackGenerator.cxx CPack/cmCPackLog.cxx + CPack/cmCPackInnoSetupGenerator.cxx CPack/cmCPackNSISGenerator.cxx CPack/cmCPackNuGetGenerator.cxx CPack/cmCPackSTGZGenerator.cxx diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 832d93c..ba16d15 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 26) -set(CMake_VERSION_PATCH 20230427) +set(CMake_VERSION_PATCH 20230504) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/CPack/IFW/cmCPackIFWCommon.cxx b/Source/CPack/IFW/cmCPackIFWCommon.cxx index 4ff3a10..4a868ae 100644 --- a/Source/CPack/IFW/cmCPackIFWCommon.cxx +++ b/Source/CPack/IFW/cmCPackIFWCommon.cxx @@ -80,15 +80,15 @@ void cmCPackIFWCommon::ExpandListArgument( return; } - cmList::index_type i = 0; - std::size_t c = args.size(); + cmList::size_type i = 0; + auto c = args.size(); if (c % 2) { argsOut[""] = args[i]; ++i; } --c; - for (; i < static_cast<cmList::index_type>(c); i += 2) { + for (; i < c; i += 2) { argsOut[args[i]] = args[i + 1]; } } @@ -101,15 +101,15 @@ void cmCPackIFWCommon::ExpandListArgument( return; } - cmList::index_type i = 0; - std::size_t c = args.size(); + cmList::size_type i = 0; + auto c = args.size(); if (c % 2) { argsOut.insert(std::pair<std::string, std::string>("", args[i])); ++i; } --c; - for (; i < static_cast<cmList::index_type>(c); i += 2) { + for (; i < c; i += 2) { argsOut.insert(std::pair<std::string, std::string>(args[i], args[i + 1])); } } diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.cxx b/Source/CPack/IFW/cmCPackIFWInstaller.cxx index 69440d9..a77c22f 100644 --- a/Source/CPack/IFW/cmCPackIFWInstaller.cxx +++ b/Source/CPack/IFW/cmCPackIFWInstaller.cxx @@ -12,6 +12,7 @@ #include "cmCPackIFWRepository.h" #include "cmCPackLog.h" // IWYU pragma: keep #include "cmGeneratedFileStream.h" +#include "cmList.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmValue.h" diff --git a/Source/CPack/IFW/cmCPackIFWPackage.cxx b/Source/CPack/IFW/cmCPackIFWPackage.cxx index b759eff..083f1ef 100644 --- a/Source/CPack/IFW/cmCPackIFWPackage.cxx +++ b/Source/CPack/IFW/cmCPackIFWPackage.cxx @@ -428,16 +428,16 @@ int cmCPackIFWPackage::ConfigureFromPrefix(const std::string& prefix) } // QtIFW dependencies - std::vector<std::string> deps; + cmList deps; option = prefix + "DEPENDS"; if (cmValue value = this->GetOption(option)) { - cmExpandList(value, deps); + deps.assign(value); } option = prefix + "DEPENDENCIES"; if (cmValue value = this->GetOption(option)) { - cmExpandList(value, deps); + deps.append(value); } - for (std::string const& d : deps) { + for (auto const& d : deps) { DependenceStruct dep(d); if (this->Generator->Packages.count(dep.Name)) { cmCPackIFWPackage& depPkg = this->Generator->Packages[dep.Name]; diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 1ce346f..1ea78fd 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -681,10 +681,10 @@ bool cmCPackWIXGenerator::AddComponentsToFeature( featureDefinitions.BeginElement("FeatureRef"); featureDefinitions.AddAttribute("Id", featureId); - std::vector<std::string> cpackPackageExecutablesList; + cmList cpackPackageExecutablesList; cmValue cpackPackageExecutables = GetOption("CPACK_PACKAGE_EXECUTABLES"); if (cpackPackageExecutables) { - cmExpandList(cpackPackageExecutables, cpackPackageExecutablesList); + cpackPackageExecutablesList.assign(cpackPackageExecutables); if (cpackPackageExecutablesList.size() % 2 != 0) { cmCPackLogger( cmCPackLog::LOG_ERROR, @@ -695,10 +695,10 @@ bool cmCPackWIXGenerator::AddComponentsToFeature( } } - std::vector<std::string> cpackPackageDesktopLinksList; + cmList cpackPackageDesktopLinksList; cmValue cpackPackageDesktopLinks = GetOption("CPACK_CREATE_DESKTOP_LINKS"); if (cpackPackageDesktopLinks) { - cmExpandList(cpackPackageDesktopLinks, cpackPackageDesktopLinksList); + cpackPackageDesktopLinksList.assign(cpackPackageDesktopLinks); } AddDirectoryAndFileDefinitions( diff --git a/Source/CPack/WiX/cmWIXAccessControlList.cxx b/Source/CPack/WiX/cmWIXAccessControlList.cxx index 9685a7f..2261a66 100644 --- a/Source/CPack/WiX/cmWIXAccessControlList.cxx +++ b/Source/CPack/WiX/cmWIXAccessControlList.cxx @@ -19,10 +19,9 @@ cmWIXAccessControlList::cmWIXAccessControlList( bool cmWIXAccessControlList::Apply() { - std::vector<std::string> entries; - this->InstalledFile.GetPropertyAsList("CPACK_WIX_ACL", entries); + auto entries = this->InstalledFile.GetPropertyAsList("CPACK_WIX_ACL"); - for (std::string const& entry : entries) { + for (auto const& entry : entries) { this->CreatePermissionElement(entry); } diff --git a/Source/CPack/WiX/cmWIXShortcut.cxx b/Source/CPack/WiX/cmWIXShortcut.cxx index cd1988a..c3eb219 100644 --- a/Source/CPack/WiX/cmWIXShortcut.cxx +++ b/Source/CPack/WiX/cmWIXShortcut.cxx @@ -91,10 +91,9 @@ void cmWIXShortcuts::CreateFromProperty(std::string const& propertyName, std::string const& directoryId, cmInstalledFile const& installedFile) { - std::vector<std::string> list; - installedFile.GetPropertyAsList(propertyName, list); + auto list = installedFile.GetPropertyAsList(propertyName); - for (std::string const& label : list) { + for (auto const& label : list) { cmWIXShortcut shortcut; shortcut.label = label; shortcut.workingDirectoryId = directoryId; diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index 2a0409d..768bfbe 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -543,9 +543,9 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, std::string sla_xml = cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), "/sla.xml"); - std::vector<std::string> languages; + cmList languages; if (!oldStyle) { - cmExpandList(cpack_dmg_languages, languages); + languages.assign(cpack_dmg_languages); } std::vector<uint16_t> header_data; @@ -574,7 +574,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, header_data.push_back(0); header_data.push_back(languages.size()); - for (size_t i = 0; i < languages.size(); ++i) { + for (cmList::size_type i = 0; i < languages.size(); ++i) { CFStringRef language_cfstring = CFStringCreateWithCString( nullptr, languages[i].c_str(), kCFStringEncodingUTF8); CFStringRef iso_language = diff --git a/Source/CPack/cmCPackExternalGenerator.cxx b/Source/CPack/cmCPackExternalGenerator.cxx index 4c92592..8ba015c 100644 --- a/Source/CPack/cmCPackExternalGenerator.cxx +++ b/Source/CPack/cmCPackExternalGenerator.cxx @@ -15,8 +15,8 @@ #include "cmCPackComponentGroup.h" #include "cmCPackLog.h" +#include "cmList.h" #include "cmMakefile.h" -#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmValue.h" @@ -79,7 +79,7 @@ int cmCPackExternalGenerator::PackageFiles() cmValue builtPackages = this->GetOption("CPACK_EXTERNAL_BUILT_PACKAGES"); if (builtPackages) { - cmExpandList(builtPackages, this->packageFileNames, false); + cmExpandList(builtPackages, this->packageFileNames); } } diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 83194a6..afd85cd 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -573,7 +573,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( ++it; project.SubDirectory = *it; - std::vector<std::string> componentsVector; + cmList componentsList; bool componentInstall = false; /* @@ -588,7 +588,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( std::string installTypesVar = "CPACK_" + cmSystemTools::UpperCase(project.Component) + "_INSTALL_TYPES"; cmValue installTypes = this->GetOption(installTypesVar); - if (cmNonempty(installTypes)) { + if (!installTypes.IsEmpty()) { cmList installTypesList{ installTypes }; for (std::string const& installType : installTypesList) { project.InstallationTypes.push_back( @@ -600,23 +600,23 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( std::string componentsVar = "CPACK_COMPONENTS_" + cmSystemTools::UpperCase(project.Component); cmValue components = this->GetOption(componentsVar); - if (cmNonempty(components)) { - cmExpandList(components, componentsVector); - for (std::string const& comp : componentsVector) { + if (!components.IsEmpty()) { + componentsList.assign(components); + for (auto const& comp : componentsList) { project.Components.push_back( this->GetComponent(project.ProjectName, comp)); } componentInstall = true; } } - if (componentsVector.empty()) { - componentsVector.push_back(project.Component); + if (componentsList.empty()) { + componentsList.push_back(project.Component); } - std::vector<std::string> buildConfigs; + cmList buildConfigs; // Try get configuration names given via `-C` CLI option - cmExpandList(this->GetOption("CPACK_BUILD_CONFIG"), buildConfigs); + buildConfigs.assign(this->GetOption("CPACK_BUILD_CONFIG")); // Remove duplicates std::sort(buildConfigs.begin(), buildConfigs.end()); @@ -655,7 +655,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( << buildConfig << ']' << std::endl); // Run the installation for each component - for (std::string const& component : componentsVector) { + for (std::string const& component : componentsList) { if (!this->InstallCMakeProject( setDestDir, project.Directory, baseTempInstallDirectory, default_dir_mode, component, componentInstall, @@ -888,9 +888,8 @@ int cmCPackGenerator::InstallCMakeProject( mf.AddDefinition("CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION", "1"); } - std::vector<std::string> custom_variables; - this->MakefileMap->GetDefExpandList("CPACK_CUSTOM_INSTALL_VARIABLES", - custom_variables); + cmList custom_variables{ this->MakefileMap->GetDefinition( + "CPACK_CUSTOM_INSTALL_VARIABLES") }; for (auto const& custom_variable : custom_variables) { std::string value; diff --git a/Source/CPack/cmCPackGeneratorFactory.cxx b/Source/CPack/cmCPackGeneratorFactory.cxx index efb94b9..6ca48bf 100644 --- a/Source/CPack/cmCPackGeneratorFactory.cxx +++ b/Source/CPack/cmCPackGeneratorFactory.cxx @@ -13,6 +13,7 @@ #include "cmCPackDebGenerator.h" #include "cmCPackExternalGenerator.h" #include "cmCPackGenerator.h" +#include "cmCPackInnoSetupGenerator.h" #include "cmCPackLog.h" #include "cmCPackNSISGenerator.h" #include "cmCPackNuGetGenerator.h" @@ -60,6 +61,10 @@ cmCPackGeneratorFactory::cmCPackGeneratorFactory() this->RegisterGenerator("STGZ", "Self extracting Tar GZip compression", cmCPackSTGZGenerator::CreateGenerator); } + if (cmCPackInnoSetupGenerator::CanGenerate()) { + this->RegisterGenerator("INNOSETUP", "Inno Setup packages", + cmCPackInnoSetupGenerator::CreateGenerator); + } if (cmCPackNSISGenerator::CanGenerate()) { this->RegisterGenerator("NSIS", "Null Soft Installer", cmCPackNSISGenerator::CreateGenerator); diff --git a/Source/CPack/cmCPackInnoSetupGenerator.cxx b/Source/CPack/cmCPackInnoSetupGenerator.cxx new file mode 100644 index 0000000..d8825d4 --- /dev/null +++ b/Source/CPack/cmCPackInnoSetupGenerator.cxx @@ -0,0 +1,1159 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying +file Copyright.txt or https://cmake.org/licensing for details. */ + +#include "cmCPackInnoSetupGenerator.h" + +#include <algorithm> +#include <cctype> +#include <cstdlib> +#include <ostream> +#include <stack> +#include <utility> + +#include "cmsys/RegularExpression.hxx" + +#include "cmCPackComponentGroup.h" +#include "cmCPackLog.h" +#include "cmDuration.h" +#include "cmGeneratedFileStream.h" +#include "cmList.h" +#include "cmStringAlgorithms.h" +#include "cmSystemTools.h" + +cmCPackInnoSetupGenerator::cmCPackInnoSetupGenerator() = default; +cmCPackInnoSetupGenerator::~cmCPackInnoSetupGenerator() = default; + +bool cmCPackInnoSetupGenerator::CanGenerate() +{ + // Inno Setup is only available for Windows +#ifdef _WIN32 + return true; +#else + return false; +#endif +} + +int cmCPackInnoSetupGenerator::InitializeInternal() +{ + if (cmIsOn(GetOption("CPACK_INCLUDE_TOPLEVEL_DIRECTORY"))) { + cmCPackLogger(cmCPackLog::LOG_WARNING, + "Inno Setup Generator cannot work with " + "CPACK_INCLUDE_TOPLEVEL_DIRECTORY set. " + "This option will be reset to 0 (for this generator only)." + << std::endl); + SetOption("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", nullptr); + } + + std::vector<std::string> path; + +#ifdef _WIN32 + path.push_back("C:\\Program Files (x86)\\Inno Setup 5"); + path.push_back("C:\\Program Files (x86)\\Inno Setup 6"); +#endif + + SetOptionIfNotSet("CPACK_INNOSETUP_EXECUTABLE", "ISCC"); + const std::string& isccPath = cmSystemTools::FindProgram( + GetOption("CPACK_INNOSETUP_EXECUTABLE"), path, false); + + if (isccPath.empty()) { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Cannot find Inno Setup compiler ISCC: " + "likely it is not installed, or not in your PATH" + << std::endl); + + return 0; + } + + const std::string isccCmd = cmStrCat(QuotePath(isccPath), "/?"); + cmCPackLogger(cmCPackLog::LOG_VERBOSE, + "Test Inno Setup version: " << isccCmd << std::endl); + std::string output; + cmSystemTools::RunSingleCommand(isccCmd, &output, &output, nullptr, nullptr, + this->GeneratorVerbose, cmDuration::zero()); + cmsys::RegularExpression vRex("Inno Setup ([0-9]+)"); + if (!vRex.find(output)) { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Problem checking Inno Setup version with command: " + << isccCmd << std::endl + << "Have you downloaded Inno Setup from " + "https://jrsoftware.org/isinfo.php?" + << std::endl); + return 0; + } + + const int isccVersion = atoi(vRex.match(1).c_str()); + const int minIsccVersion = 6; + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "Inno Setup Version: " << isccVersion << std::endl); + + if (isccVersion < minIsccVersion) { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "CPack requires Inno Setup Version 6 or greater. " + "Inno Setup found on the system was: " + << isccVersion << std::endl); + return 0; + } + + SetOption("CPACK_INSTALLER_PROGRAM", isccPath); + + return this->Superclass::InitializeInternal(); +} + +int cmCPackInnoSetupGenerator::PackageFiles() +{ + // Includes + if (IsSet("CPACK_INNOSETUP_EXTRA_SCRIPTS")) { + const cmList extraScripts(GetOption("CPACK_INNOSETUP_EXTRA_SCRIPTS")); + + for (const std::string& i : extraScripts) { + includeDirectives.push_back(cmStrCat( + "#include ", QuotePath(cmSystemTools::CollapseFullPath(i, toplevel)))); + } + } + + // [Languages] section + SetOptionIfNotSet("CPACK_INNOSETUP_LANGUAGES", "english"); + const cmList languages(GetOption("CPACK_INNOSETUP_LANGUAGES")); + for (std::string i : languages) { + cmCPackInnoSetupKeyValuePairs params; + + params["Name"] = Quote(i); + + if (cmSystemTools::LowerCase(i) == "english") { + params["MessagesFile"] = "\"compiler:Default.isl\""; + } else { + i[0] = static_cast<char>(std::toupper(i[0])); + params["MessagesFile"] = cmStrCat("\"compiler:Languages\\", i, ".isl\""); + } + + languageInstructions.push_back(ISKeyValueLine(params)); + } + + if (!Components.empty() && !ProcessComponents()) { + return false; + } + + if (!(ProcessSetupSection() && ProcessFiles())) { + return false; + } + + // [Code] section + if (IsSet("CPACK_INNOSETUP_CODE_FILES")) { + const cmList codeFiles(GetOption("CPACK_INNOSETUP_CODE_FILES")); + + for (const std::string& i : codeFiles) { + codeIncludes.push_back(cmStrCat( + "#include ", QuotePath(cmSystemTools::CollapseFullPath(i, toplevel)))); + } + } + + return ConfigureISScript() && Compile(); +} + +bool cmCPackInnoSetupGenerator::ProcessSetupSection() +{ + if (!RequireOption("CPACK_PACKAGE_INSTALL_REGISTRY_KEY")) { + return false; + } + setupDirectives["AppId"] = GetOption("CPACK_PACKAGE_INSTALL_REGISTRY_KEY"); + + if (!RequireOption("CPACK_PACKAGE_NAME")) { + return false; + } + setupDirectives["AppName"] = GetOption("CPACK_PACKAGE_NAME"); + setupDirectives["UninstallDisplayName"] = GetOption("CPACK_PACKAGE_NAME"); + + if (!RequireOption("CPACK_PACKAGE_VERSION")) { + return false; + } + setupDirectives["AppVersion"] = GetOption("CPACK_PACKAGE_VERSION"); + + if (!RequireOption("CPACK_PACKAGE_VENDOR")) { + return false; + } + setupDirectives["AppPublisher"] = GetOption("CPACK_PACKAGE_VENDOR"); + + if (IsSet("CPACK_PACKAGE_HOMEPAGE_URL")) { + setupDirectives["AppPublisherURL"] = + GetOption("CPACK_PACKAGE_HOMEPAGE_URL"); + setupDirectives["AppSupportURL"] = GetOption("CPACK_PACKAGE_HOMEPAGE_URL"); + setupDirectives["AppUpdatesURL"] = GetOption("CPACK_PACKAGE_HOMEPAGE_URL"); + } + + SetOptionIfNotSet("CPACK_INNOSETUP_IGNORE_LICENSE_PAGE", "OFF"); + if (IsSet("CPACK_RESOURCE_FILE_LICENSE") && + !GetOption("CPACK_INNOSETUP_IGNORE_LICENSE_PAGE").IsOn()) { + setupDirectives["LicenseFile"] = cmSystemTools::ConvertToWindowsOutputPath( + GetOption("CPACK_RESOURCE_FILE_LICENSE")); + } + + SetOptionIfNotSet("CPACK_INNOSETUP_IGNORE_README_PAGE", "ON"); + if (IsSet("CPACK_RESOURCE_FILE_README") && + !GetOption("CPACK_INNOSETUP_IGNORE_README_PAGE").IsOn()) { + setupDirectives["InfoBeforeFile"] = + cmSystemTools::ConvertToWindowsOutputPath( + GetOption("CPACK_RESOURCE_FILE_README")); + } + + SetOptionIfNotSet("CPACK_INNOSETUP_USE_MODERN_WIZARD", "OFF"); + if (GetOption("CPACK_INNOSETUP_USE_MODERN_WIZARD").IsOn()) { + setupDirectives["WizardStyle"] = "modern"; + } else { + setupDirectives["WizardStyle"] = "classic"; + setupDirectives["WizardSmallImageFile"] = + "compiler:WizClassicSmallImage.bmp"; + setupDirectives["WizardImageFile"] = "compiler:WizClassicImage.bmp"; + setupDirectives["SetupIconFile"] = "compiler:SetupClassicIcon.ico"; + } + + if (IsSet("CPACK_INNOSETUP_ICON_FILE")) { + setupDirectives["SetupIconFile"] = + cmSystemTools::ConvertToWindowsOutputPath( + GetOption("CPACK_INNOSETUP_ICON_FILE")); + } + + if (IsSet("CPACK_PACKAGE_ICON")) { + setupDirectives["WizardSmallImageFile"] = + cmSystemTools::ConvertToWindowsOutputPath( + GetOption("CPACK_PACKAGE_ICON")); + } + + if (!RequireOption("CPACK_PACKAGE_INSTALL_DIRECTORY")) { + return false; + } + SetOptionIfNotSet("CPACK_INNOSETUP_INSTALL_ROOT", "{autopf}"); + setupDirectives["DefaultDirName"] = + cmSystemTools::ConvertToWindowsOutputPath( + cmStrCat(GetOption("CPACK_INNOSETUP_INSTALL_ROOT"), '\\', + GetOption("CPACK_PACKAGE_INSTALL_DIRECTORY"))); + + SetOptionIfNotSet("CPACK_INNOSETUP_ALLOW_CUSTOM_DIRECTORY", "ON"); + if (GetOption("CPACK_INNOSETUP_ALLOW_CUSTOM_DIRECTORY").IsOff()) { + setupDirectives["DisableDirPage"] = "yes"; + } + + SetOptionIfNotSet("CPACK_INNOSETUP_PROGRAM_MENU_FOLDER", + GetOption("CPACK_PACKAGE_NAME")); + if (GetOption("CPACK_INNOSETUP_PROGRAM_MENU_FOLDER") == ".") { + setupDirectives["DisableProgramGroupPage"] = "yes"; + toplevelProgramFolder = true; + } else { + setupDirectives["DefaultGroupName"] = + GetOption("CPACK_INNOSETUP_PROGRAM_MENU_FOLDER"); + toplevelProgramFolder = false; + } + + if (IsSet("CPACK_INNOSETUP_PASSWORD")) { + setupDirectives["Password"] = GetOption("CPACK_INNOSETUP_PASSWORD"); + setupDirectives["Encryption"] = "yes"; + } + + /* + * These directives can only be modified using the + * CPACK_INNOSETUP_SETUP_<directive> variables + */ + setupDirectives["ShowLanguageDialog"] = "auto"; + setupDirectives["AllowNoIcons"] = "yes"; + setupDirectives["Compression"] = "lzma"; + setupDirectives["SolidCompression"] = "yes"; + + // Output file and directory + if (!RequireOption("CPACK_PACKAGE_FILE_NAME")) { + return false; + } + setupDirectives["OutputBaseFilename"] = GetOption("CPACK_PACKAGE_FILE_NAME"); + + if (!RequireOption("CPACK_TOPLEVEL_DIRECTORY")) { + return false; + } + setupDirectives["OutputDir"] = cmSystemTools::ConvertToWindowsOutputPath( + GetOption("CPACK_TOPLEVEL_DIRECTORY")); + + setupDirectives["SourceDir"] = + cmSystemTools::ConvertToWindowsOutputPath(toplevel); + + // Target architecture + if (!RequireOption("CPACK_INNOSETUP_ARCHITECTURE")) { + return false; + } + + const std::string& architecture = GetOption("CPACK_INNOSETUP_ARCHITECTURE"); + if (architecture != "x86" && architecture != "x64" && + architecture != "arm64" && architecture != "ia64") { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "CPACK_INNOSETUP_ARCHITECTURE must be either x86, x64, " + "arm64 or ia64" + << std::endl); + return false; + } + + // The following directives must not be set to target x86 + if (architecture != "x86") { + setupDirectives["ArchitecturesAllowed"] = architecture; + setupDirectives["ArchitecturesInstallIn64BitMode"] = architecture; + } + + /* + * Handle custom directives (they have higher priority than other variables, + * so they have to be processed after all other variables) + */ + for (const std::string& i : GetOptions()) { + if (cmHasPrefix(i, "CPACK_INNOSETUP_SETUP_")) { + const std::string& directive = + i.substr(cmStrLen("CPACK_INNOSETUP_SETUP_")); + setupDirectives[directive] = GetOption(i); + } + } + + return true; +} + +bool cmCPackInnoSetupGenerator::ProcessFiles() +{ + std::map<std::string, std::string> customFileInstructions; + if (IsSet("CPACK_INNOSETUP_CUSTOM_INSTALL_INSTRUCTIONS")) { + const cmList instructions( + GetOption("CPACK_INNOSETUP_CUSTOM_INSTALL_INSTRUCTIONS")); + if (instructions.size() % 2 != 0) { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "CPACK_INNOSETUP_CUSTOM_INSTALL_INSTRUCTIONS should " + "contain pairs of <path> and <instruction>" + << std::endl); + return false; + } + + for (auto it = instructions.begin(); it != instructions.end(); ++it) { + const std::string& key = + QuotePath(cmSystemTools::CollapseFullPath(*it, toplevel)); + customFileInstructions[key] = *(++it); + } + } + + const std::string& iconsPrefix = + toplevelProgramFolder ? "{autoprograms}\\" : "{group}\\"; + + std::map<std::string, std::string> icons; + if (IsSet("CPACK_PACKAGE_EXECUTABLES")) { + const cmList executables(GetOption("CPACK_PACKAGE_EXECUTABLES")); + if (executables.size() % 2 != 0) { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "CPACK_PACKAGE_EXECUTABLES should should contain pairs of " + "<executable> and <text label>" + << std::endl); + return false; + } + + for (auto it = executables.begin(); it != executables.end(); ++it) { + const std::string& key = *it; + icons[key] = *(++it); + } + } + + std::vector<std::string> desktopIcons; + if (IsSet("CPACK_CREATE_DESKTOP_LINKS")) { + cmExpandList(GetOption("CPACK_CREATE_DESKTOP_LINKS"), desktopIcons); + } + + std::vector<std::string> runExecutables; + if (IsSet("CPACK_INNOSETUP_RUN_EXECUTABLES")) { + cmExpandList(GetOption("CPACK_INNOSETUP_RUN_EXECUTABLES"), runExecutables); + } + + for (const std::string& i : files) { + cmCPackInnoSetupKeyValuePairs params; + + std::string toplevelDirectory; + std::string outputDir; + cmCPackComponent* component = nullptr; + std::string componentParam; + if (!Components.empty()) { + const std::string& fileName = cmSystemTools::RelativePath(toplevel, i); + const std::string::size_type pos = fileName.find('/'); + + // Use the custom component install directory if we have one + if (pos != std::string::npos) { + const std::string& componentName = fileName.substr(0, pos); + component = &Components[componentName]; + + toplevelDirectory = + cmSystemTools::CollapseFullPath(componentName, toplevel); + outputDir = CustomComponentInstallDirectory(component); + componentParam = + CreateRecursiveComponentPath(component->Group, component->Name); + + if (component->IsHidden && component->IsDisabledByDefault) { + continue; + } + + if (component->IsHidden) { + componentParam.clear(); + } + } else { + // Don't install component directories + continue; + } + } else { + toplevelDirectory = toplevel; + outputDir = "{app}"; + } + + if (!componentParam.empty()) { + params["Components"] = componentParam; + } + + if (cmSystemTools::FileIsDirectory(i)) { + // Custom instructions replace the automatic generated instructions + if (customFileInstructions.count(QuotePath(i))) { + dirInstructions.push_back(customFileInstructions[QuotePath(i)]); + } else { + std::string destDir = cmSystemTools::ConvertToWindowsOutputPath( + cmStrCat(outputDir, '\\', + cmSystemTools::RelativePath(toplevelDirectory, i))); + cmStripSuffixIfExists(destDir, '\\'); + + params["Name"] = QuotePath(destDir); + + dirInstructions.push_back(ISKeyValueLine(params)); + } + } else { + // Custom instructions replace the automatic generated instructions + if (customFileInstructions.count(QuotePath(i))) { + fileInstructions.push_back(customFileInstructions[QuotePath(i)]); + } else { + std::string destDir = cmSystemTools::ConvertToWindowsOutputPath( + cmStrCat(outputDir, '\\', + cmSystemTools::GetParentDirectory( + cmSystemTools::RelativePath(toplevelDirectory, i)))); + cmStripSuffixIfExists(destDir, '\\'); + + params["DestDir"] = QuotePath(destDir); + + if (component != nullptr && component->IsDownloaded) { + const std::string& archiveName = + cmSystemTools::GetFilenameWithoutLastExtension( + component->ArchiveFile); + const std::string& relativePath = + cmSystemTools::RelativePath(toplevelDirectory, i); + + params["Source"] = + QuotePath(cmStrCat("{tmp}\\", archiveName, '\\', relativePath)); + params["ExternalSize"] = + std::to_string(cmSystemTools::FileLength(i)); + params["Flags"] = "external ignoreversion"; + params["BeforeInstall"] = + cmStrCat("CPackExtractFile('", archiveName, "', '", + cmRemoveQuotes(cmSystemTools::ConvertToWindowsOutputPath( + relativePath)), + "')"); + } else { + params["Source"] = QuotePath(i); + params["Flags"] = "ignoreversion"; + } + + fileInstructions.push_back(ISKeyValueLine(params)); + + // Icon + const std::string& name = + cmSystemTools::GetFilenameWithoutLastExtension(i); + const std::string& extension = + cmSystemTools::GetFilenameLastExtension(i); + if ((extension == ".exe" || extension == ".com") && // only .exe, .com + icons.count(name)) { + cmCPackInnoSetupKeyValuePairs iconParams; + + iconParams["Name"] = QuotePath(cmStrCat(iconsPrefix, icons[name])); + iconParams["Filename"] = + QuotePath(cmStrCat(destDir, '\\', name, extension)); + + if (!componentParam.empty()) { + iconParams["Components"] = componentParam; + } + + iconInstructions.push_back(ISKeyValueLine(iconParams)); + + // Desktop icon + if (std::find(desktopIcons.begin(), desktopIcons.end(), name) != + desktopIcons.end()) { + iconParams["Name"] = + QuotePath(cmStrCat("{autodesktop}\\", icons[name])); + iconParams["Tasks"] = "desktopicon"; + + if (!componentParam.empty() && + std::find(desktopIconComponents.begin(), + desktopIconComponents.end(), + componentParam) == desktopIconComponents.end()) { + desktopIconComponents.push_back(componentParam); + } + iconInstructions.push_back(ISKeyValueLine(iconParams)); + } + + // [Run] section + if (std::find(runExecutables.begin(), runExecutables.end(), name) != + runExecutables.end()) { + cmCPackInnoSetupKeyValuePairs runParams; + + runParams["Filename"] = iconParams["Filename"]; + runParams["Description"] = cmStrCat( + "\"{cm:LaunchProgram,", PrepareForConstant(icons[name]), "}\""); + runParams["Flags"] = "nowait postinstall skipifsilent"; + + if (!componentParam.empty()) { + runParams["Components"] = componentParam; + } + + runInstructions.push_back(ISKeyValueLine(runParams)); + } + } + } + } + } + + // Additional icons + static cmsys::RegularExpression urlRegex( + "^(mailto:|(ftps?|https?|news)://).*$"); + + if (IsSet("CPACK_INNOSETUP_MENU_LINKS")) { + const cmList menuIcons(GetOption("CPACK_INNOSETUP_MENU_LINKS")); + if (menuIcons.size() % 2 != 0) { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "CPACK_INNOSETUP_MENU_LINKS should " + "contain pairs of <shortcut target> and <shortcut label>" + << std::endl); + return false; + } + + for (auto it = menuIcons.begin(); it != menuIcons.end(); ++it) { + const std::string& target = *it; + const std::string& label = *(++it); + cmCPackInnoSetupKeyValuePairs params; + + params["Name"] = QuotePath(cmStrCat(iconsPrefix, label)); + if (urlRegex.find(target)) { + params["Filename"] = Quote(target); + } else { + std::string dir = "{app}"; + std::string componentName; + for (const auto& i : Components) { + if (cmSystemTools::FileExists(cmSystemTools::CollapseFullPath( + cmStrCat(i.second.Name, '\\', target), toplevel))) { + dir = CustomComponentInstallDirectory(&i.second); + componentName = + CreateRecursiveComponentPath(i.second.Group, i.second.Name); + + if (i.second.IsHidden && i.second.IsDisabledByDefault) { + goto continueOuterLoop; + } else if (i.second.IsHidden) { + componentName.clear(); + } + + break; + } + } + + params["Filename"] = QuotePath(cmStrCat(dir, '\\', target)); + + if (!componentName.empty()) { + params["Components"] = componentName; + } + } + + iconInstructions.push_back(ISKeyValueLine(params)); + continueOuterLoop:; + } + } + + SetOptionIfNotSet("CPACK_INNOSETUP_CREATE_UNINSTALL_LINK", "OFF"); + if (GetOption("CPACK_INNOSETUP_CREATE_UNINSTALL_LINK").IsOn()) { + cmCPackInnoSetupKeyValuePairs params; + + params["Name"] = QuotePath( + cmStrCat(iconsPrefix, "{cm:UninstallProgram,", + PrepareForConstant(GetOption("CPACK_PACKAGE_NAME")), '}')); + params["Filename"] = "\"{uninstallexe}\""; + + iconInstructions.push_back(ISKeyValueLine(params)); + } + + return true; +} + +bool cmCPackInnoSetupGenerator::ProcessComponents() +{ + codeIncludes.push_back("{ The following lines are required by CPack because " + "this script uses components }"); + + // Installation types + bool noTypes = true; + std::vector<cmCPackInstallationType*> types(InstallationTypes.size()); + for (auto& i : InstallationTypes) { + noTypes = false; + types[i.second.Index - 1] = &i.second; + } + + std::vector<std::string> allTypes; // For required components + for (cmCPackInstallationType* i : types) { + cmCPackInnoSetupKeyValuePairs params; + + params["Name"] = Quote(i->Name); + params["Description"] = Quote(i->DisplayName); + + allTypes.push_back(i->Name); + typeInstructions.push_back(ISKeyValueLine(params)); + } + + if (!noTypes) { + // Inno Setup requires the "custom" type + cmCPackInnoSetupKeyValuePairs params; + + params["Name"] = "\"custom\""; + params["Description"] = "\"{code:CPackGetCustomInstallationMessage}\""; + params["Flags"] = "iscustom"; + + allTypes.push_back("custom"); + typeInstructions.push_back(ISKeyValueLine(params)); + } + + // Components + std::vector<cmCPackComponent*> downloadedComponents; + std::stack<cmCPackComponentGroup*> groups; + for (auto& i : Components) { + cmCPackInnoSetupKeyValuePairs params; + cmCPackComponent* component = &i.second; + + if (component->IsHidden) { + continue; + } + + CreateRecursiveComponentGroups(component->Group); + + params["Name"] = + Quote(CreateRecursiveComponentPath(component->Group, component->Name)); + params["Description"] = Quote(component->DisplayName); + + if (component->IsRequired) { + params["Types"] = cmJoin(allTypes, " "); + params["Flags"] = "fixed"; + } else if (!component->InstallationTypes.empty()) { + std::vector<std::string> installationTypes; + + for (cmCPackInstallationType* j : component->InstallationTypes) { + installationTypes.push_back(j->Name); + } + + params["Types"] = cmJoin(installationTypes, " "); + } + + componentInstructions.push_back(ISKeyValueLine(params)); + + if (component->IsDownloaded) { + downloadedComponents.push_back(component); + + if (component->ArchiveFile.empty()) { + // Compute the name of the archive. + if (!RequireOption("CPACK_TEMPORARY_DIRECTORY")) { + return false; + } + + std::string packagesDir = + cmStrCat(GetOption("CPACK_TEMPORARY_DIRECTORY"), ".dummy"); + component->ArchiveFile = + cmStrCat(cmSystemTools::GetFilenameWithoutLastExtension(packagesDir), + '-', component->Name, ".zip"); + } else if (!cmHasSuffix(component->ArchiveFile, ".zip")) { + component->ArchiveFile = cmStrCat(component->ArchiveFile, ".zip"); + } + } + } + + // Downloaded components + if (!downloadedComponents.empty()) { + // Create the directory for the upload area + cmValue userUploadDirectory = GetOption("CPACK_UPLOAD_DIRECTORY"); + std::string uploadDirectory; + if (cmNonempty(userUploadDirectory)) { + uploadDirectory = *userUploadDirectory; + } else { + if (!RequireOption("CPACK_PACKAGE_DIRECTORY")) { + return false; + } + + uploadDirectory = + cmStrCat(GetOption("CPACK_PACKAGE_DIRECTORY"), "/CPackUploads"); + } + + if (!cmSystemTools::FileExists(uploadDirectory)) { + if (!cmSystemTools::MakeDirectory(uploadDirectory)) { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Unable to create Inno Setup upload directory " + << uploadDirectory << std::endl); + return false; + } + } + + if (!RequireOption("CPACK_DOWNLOAD_SITE")) { + return false; + } + + SetOptionIfNotSet("CPACK_INNOSETUP_VERIFY_DOWNLOADS", "ON"); + const bool verifyDownloads = + GetOption("CPACK_INNOSETUP_VERIFY_DOWNLOADS").IsOn(); + + const std::string& urlPrefix = + cmHasSuffix(GetOption("CPACK_DOWNLOAD_SITE").GetCStr(), '/') + ? GetOption("CPACK_DOWNLOAD_SITE") + : cmStrCat(GetOption("CPACK_DOWNLOAD_SITE"), '/'); + + std::vector<std::string> archiveUrls; + std::vector<std::string> archiveFiles; + std::vector<std::string> archiveHashes; + std::vector<std::string> archiveComponents; + for (cmCPackComponent* i : downloadedComponents) { + std::string hash; + if (!BuildDownloadedComponentArchive( + i, uploadDirectory, (verifyDownloads ? &hash : nullptr))) { + return false; + } + + archiveUrls.push_back(Quote(cmStrCat(urlPrefix, i->ArchiveFile))); + archiveFiles.push_back( + Quote(cmSystemTools::GetFilenameWithoutLastExtension(i->ArchiveFile))); + archiveHashes.push_back(Quote(hash)); + archiveComponents.push_back( + Quote(CreateRecursiveComponentPath(i->Group, i->Name))); + } + + SetOption("CPACK_INNOSETUP_DOWNLOAD_COUNT_INTERNAL", + std::to_string(archiveFiles.size())); + SetOption("CPACK_INNOSETUP_DOWNLOAD_URLS_INTERNAL", + cmJoin(archiveUrls, ", ")); + SetOption("CPACK_INNOSETUP_DOWNLOAD_ARCHIVES_INTERNAL", + cmJoin(archiveFiles, ", ")); + SetOption("CPACK_INNOSETUP_DOWNLOAD_HASHES_INTERNAL", + cmJoin(archiveHashes, ", ")); + SetOption("CPACK_INNOSETUP_DOWNLOAD_COMPONENTS_INTERNAL", + cmJoin(archiveComponents, ", ")); + + static const std::string& downloadLines = + "#define protected CPackDownloadCount " + "@CPACK_INNOSETUP_DOWNLOAD_COUNT_INTERNAL@\n" + "#dim protected CPackDownloadUrls[CPackDownloadCount] " + "{@CPACK_INNOSETUP_DOWNLOAD_URLS_INTERNAL@}\n" + "#dim protected CPackDownloadArchives[CPackDownloadCount] " + "{@CPACK_INNOSETUP_DOWNLOAD_ARCHIVES_INTERNAL@}\n" + "#dim protected CPackDownloadHashes[CPackDownloadCount] " + "{@CPACK_INNOSETUP_DOWNLOAD_HASHES_INTERNAL@}\n" + "#dim protected CPackDownloadComponents[CPackDownloadCount] " + "{@CPACK_INNOSETUP_DOWNLOAD_COMPONENTS_INTERNAL@}"; + + std::string output; + if (!ConfigureString(downloadLines, output)) { + return false; + } + codeIncludes.push_back(output); + } + + // Add the required script + const std::string& componentsScriptTemplate = + FindTemplate("ISComponents.pas"); + if (componentsScriptTemplate.empty()) { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Could not find additional Inno Setup script file." + << std::endl); + return false; + } + + codeIncludes.push_back("#include " + QuotePath(componentsScriptTemplate) + + "\n"); + + return true; +} + +bool cmCPackInnoSetupGenerator::ConfigureISScript() +{ + const std::string& isScriptTemplate = FindTemplate("ISScript.template.in"); + const std::string& isScriptFile = + cmStrCat(GetOption("CPACK_TOPLEVEL_DIRECTORY"), "/ISScript.iss"); + + if (isScriptTemplate.empty()) { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Could not find Inno Setup installer template file." + << std::endl); + return false; + } + + // Create internal variables + std::vector<std::string> setupSection; + for (const auto& i : setupDirectives) { + setupSection.push_back(cmStrCat(i.first, '=', TranslateBool(i.second))); + } + + // Also create comments if the sections are empty + const std::string& defaultMessage = + "; CPack didn't find any entries for this section"; + + if (IsSet("CPACK_CREATE_DESKTOP_LINKS") && + !GetOption("CPACK_CREATE_DESKTOP_LINKS").Get()->empty()) { + cmCPackInnoSetupKeyValuePairs tasks; + tasks["Name"] = "\"desktopicon\""; + tasks["Description"] = "\"{cm:CreateDesktopIcon}\""; + tasks["GroupDescription"] = "\"{cm:AdditionalIcons}\""; + tasks["Flags"] = "unchecked"; + + if (!desktopIconComponents.empty()) { + tasks["Components"] = cmJoin(desktopIconComponents, " "); + } + + SetOption("CPACK_INNOSETUP_TASKS_INTERNAL", ISKeyValueLine(tasks)); + } else { + SetOption("CPACK_INNOSETUP_TASKS_INTERNAL", defaultMessage); + } + + SetOption("CPACK_INNOSETUP_INCLUDES_INTERNAL", + includeDirectives.empty() ? "; No extra script files specified" + : cmJoin(includeDirectives, "\n")); + SetOption("CPACK_INNOSETUP_SETUP_INTERNAL", + setupSection.empty() ? defaultMessage + : cmJoin(setupSection, "\n")); + SetOption("CPACK_INNOSETUP_LANGUAGES_INTERNAL", + languageInstructions.empty() ? defaultMessage + : cmJoin(languageInstructions, "\n")); + SetOption("CPACK_INNOSETUP_DIRS_INTERNAL", + dirInstructions.empty() ? defaultMessage + : cmJoin(dirInstructions, "\n")); + SetOption("CPACK_INNOSETUP_FILES_INTERNAL", + fileInstructions.empty() ? defaultMessage + : cmJoin(fileInstructions, "\n")); + SetOption("CPACK_INNOSETUP_TYPES_INTERNAL", + typeInstructions.empty() ? defaultMessage + : cmJoin(typeInstructions, "\n")); + SetOption("CPACK_INNOSETUP_COMPONENTS_INTERNAL", + componentInstructions.empty() + ? defaultMessage + : cmJoin(componentInstructions, "\n")); + SetOption("CPACK_INNOSETUP_ICONS_INTERNAL", + iconInstructions.empty() ? defaultMessage + : cmJoin(iconInstructions, "\n")); + SetOption("CPACK_INNOSETUP_RUN_INTERNAL", + runInstructions.empty() ? defaultMessage + : cmJoin(runInstructions, "\n")); + SetOption("CPACK_INNOSETUP_CODE_INTERNAL", + codeIncludes.empty() ? "{ No extra code files specified }" + : cmJoin(codeIncludes, "\n")); + + cmCPackLogger(cmCPackLog::LOG_VERBOSE, + "Configure file: " << isScriptTemplate << " to " + << isScriptFile << std::endl); + + return ConfigureFile(isScriptTemplate, isScriptFile); +} + +bool cmCPackInnoSetupGenerator::Compile() +{ + const std::string& isScriptFile = + cmStrCat(GetOption("CPACK_TOPLEVEL_DIRECTORY"), "/ISScript.iss"); + const std::string& isccLogFile = + cmStrCat(GetOption("CPACK_TOPLEVEL_DIRECTORY"), "/ISCCOutput.log"); + + std::vector<std::string> isccArgs; + + // Custom defines + for (const std::string& i : GetOptions()) { + if (cmHasPrefix(i, "CPACK_INNOSETUP_DEFINE_")) { + const std::string& name = i.substr(cmStrLen("CPACK_INNOSETUP_DEFINE_")); + isccArgs.push_back( + cmStrCat("\"/D", name, '=', TranslateBool(GetOption(i)), '"')); + } + } + + if (IsSet("CPACK_INNOSETUP_EXECUTABLE_ARGUMENTS")) { + const cmList args(GetOption("CPACK_INNOSETUP_EXECUTABLE_ARGUMENTS")); + + isccArgs.insert(isccArgs.end(), args.begin(), args.end()); + } + + const std::string& isccCmd = + cmStrCat(QuotePath(GetOption("CPACK_INSTALLER_PROGRAM")), ' ', + cmJoin(isccArgs, " "), ' ', QuotePath(isScriptFile)); + + cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << isccCmd << std::endl); + + std::string output; + int retVal = 1; + const bool res = cmSystemTools::RunSingleCommand( + isccCmd, &output, &output, &retVal, nullptr, this->GeneratorVerbose, + cmDuration::zero()); + + if (!res || retVal) { + cmGeneratedFileStream ofs(isccLogFile); + ofs << "# Run command: " << isccCmd << std::endl + << "# Output:" << std::endl + << output << std::endl; + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Problem running ISCC. Please check " + << isccLogFile << " for errors." << std::endl); + return false; + } + + return true; +} + +bool cmCPackInnoSetupGenerator::BuildDownloadedComponentArchive( + cmCPackComponent* component, const std::string& uploadDirectory, + std::string* hash) +{ + // Remove the old archive, if one exists + const std::string& archiveFile = + uploadDirectory + '/' + component->ArchiveFile; + cmCPackLogger(cmCPackLog::LOG_OUTPUT, + "- Building downloaded component archive: " << archiveFile + << std::endl); + if (cmSystemTools::FileExists(archiveFile, true)) { + if (!cmSystemTools::RemoveFile(archiveFile)) { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Unable to remove archive file " << archiveFile + << std::endl); + return false; + } + } + + // Find a ZIP program + if (!IsSet("ZIP_EXECUTABLE")) { + ReadListFile("Internal/CPack/CPackZIP.cmake"); + + if (!IsSet("ZIP_EXECUTABLE")) { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Unable to find ZIP program" << std::endl); + return false; + } + } + + if (!RequireOption("CPACK_TOPLEVEL_DIRECTORY") || + !RequireOption("CPACK_TEMPORARY_DIRECTORY") || + !RequireOption("CPACK_ZIP_NEED_QUOTES") || + !RequireOption("CPACK_ZIP_COMMAND")) { + return false; + } + + // The directory where this component's files reside + const std::string& dirName = + cmStrCat(GetOption("CPACK_TEMPORARY_DIRECTORY"), '/', component->Name); + + // Build the list of files to go into this archive + const std::string& zipListFileName = + cmStrCat(GetOption("CPACK_TEMPORARY_DIRECTORY"), "/winZip.filelist"); + const bool needQuotesInFile = cmIsOn(GetOption("CPACK_ZIP_NEED_QUOTES")); + { // the scope is needed for cmGeneratedFileStream + cmGeneratedFileStream out(zipListFileName); + for (const std::string& i : component->Files) { + out << (needQuotesInFile ? Quote(i) : i) << std::endl; + } + } + + // Build the archive in the upload area + std::string cmd = GetOption("CPACK_ZIP_COMMAND"); + cmsys::SystemTools::ReplaceString(cmd, "<ARCHIVE>", archiveFile.c_str()); + cmsys::SystemTools::ReplaceString(cmd, "<FILELIST>", + zipListFileName.c_str()); + std::string output; + int retVal = -1; + const bool res = cmSystemTools::RunSingleCommand( + cmd, &output, &output, &retVal, dirName.c_str(), this->GeneratorVerbose, + cmDuration::zero()); + if (!res || retVal) { + std::string tmpFile = + cmStrCat(GetOption("CPACK_TOPLEVEL_DIRECTORY"), "/CompressZip.log"); + cmGeneratedFileStream ofs(tmpFile); + ofs << "# Run command: " << cmd << std::endl + << "# Output:" << std::endl + << output << std::endl; + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Problem running zip command: " << cmd << std::endl + << "Please check " << tmpFile + << " for errors" + << std::endl); + return false; + } + + // Try to get the SHA256 hash of the archive file + if (hash == nullptr) { + return true; + } + +#ifdef _WIN32 + const std::string& hashCmd = + cmStrCat("certutil -hashfile ", QuotePath(archiveFile), " SHA256"); + + std::string hashOutput; + int hashRetVal = -1; + const bool hashRes = cmSystemTools::RunSingleCommand( + hashCmd, &hashOutput, &hashOutput, &hashRetVal, nullptr, + this->GeneratorVerbose, cmDuration::zero()); + if (!hashRes || hashRetVal) { + cmCPackLogger(cmCPackLog::LOG_WARNING, + "Problem running certutil command: " << hashCmd + << std::endl); + } + *hash = cmTrimWhitespace(cmTokenize(hashOutput, "\n").at(1)); + + if (hash->length() != 64) { + cmCPackLogger(cmCPackLog::LOG_WARNING, + "Problem parsing certutil output of command: " << hashCmd + << std::endl); + hash->clear(); + } +#endif + + return true; +} + +cmValue cmCPackInnoSetupGenerator::RequireOption(const std::string& key) +{ + cmValue value = GetOption(key); + + if (!value) { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Required variable " << key << " not set" << std::endl); + } + + return value; +} + +std::string cmCPackInnoSetupGenerator::CustomComponentInstallDirectory( + const cmCPackComponent* component) +{ + cmValue outputDir = GetOption( + cmStrCat("CPACK_INNOSETUP_", component->Name, "_INSTALL_DIRECTORY")); + if (outputDir) { + std::string destDir = cmSystemTools::ConvertToWindowsOutputPath(outputDir); + cmStripSuffixIfExists(destDir, '\\'); + + /* + * Add a dir instruction for the custom directory + * (only once and not for Inno Setup constants ending with '}') + */ + static std::vector<std::string> customDirectories; + if (!cmHasSuffix(destDir, '}') && + std::find(customDirectories.begin(), customDirectories.end(), + component->Name) == customDirectories.end()) { + cmCPackInnoSetupKeyValuePairs params; + params["Name"] = QuotePath(destDir); + params["Components"] = + CreateRecursiveComponentPath(component->Group, component->Name); + + dirInstructions.push_back(ISKeyValueLine(params)); + customDirectories.push_back(component->Name); + } + return destDir; + } + + return "{app}"; +} + +std::string cmCPackInnoSetupGenerator::TranslateBool(const std::string& value) +{ + if (value.empty()) { + return value; + } + + SetOptionIfNotSet("CPACK_INNOSETUP_USE_CMAKE_BOOL_FORMAT", "ON"); + if (GetOption("CPACK_INNOSETUP_USE_CMAKE_BOOL_FORMAT").IsOn()) { + if (cmIsOn(value)) { + return "yes"; + } + if (cmIsOff(value)) { + return "no"; + } + } + + return value; +} + +std::string cmCPackInnoSetupGenerator::ISKeyValueLine( + const cmCPackInnoSetupKeyValuePairs& params) +{ + /* + * To simplify readability of the generated code, the keys are sorted. + * Unknown keys are ignored to avoid errors during compilation. + */ + static const char* const availableKeys[] = { + "Source", "DestDir", "Name", "Filename", + "Description", "GroupDescription", "MessagesFile", "Types", + "ExternalSize", "BeforeInstall", "Flags", "Components", + "Tasks" + }; + + std::vector<std::string> keys; + for (const char* i : availableKeys) { + if (params.count(i)) { + keys.push_back(cmStrCat(i, ": ", params.at(i))); + } + } + + return cmJoin(keys, "; "); +} + +std::string cmCPackInnoSetupGenerator::CreateRecursiveComponentPath( + cmCPackComponentGroup* group, const std::string& path) +{ + if (group == nullptr) { + return path; + } + + const std::string& newPath = + path.empty() ? group->Name : cmStrCat(group->Name, '\\', path); + return CreateRecursiveComponentPath(group->ParentGroup, newPath); +} + +void cmCPackInnoSetupGenerator::CreateRecursiveComponentGroups( + cmCPackComponentGroup* group) +{ + if (group == nullptr) { + return; + } + + CreateRecursiveComponentGroups(group->ParentGroup); + + static std::vector<cmCPackComponentGroup*> processedGroups; + if (std::find(processedGroups.begin(), processedGroups.end(), group) == + processedGroups.end()) { + processedGroups.push_back(group); + + cmCPackInnoSetupKeyValuePairs params; + + params["Name"] = Quote(CreateRecursiveComponentPath(group)); + params["Description"] = Quote(group->DisplayName); + + componentInstructions.push_back(ISKeyValueLine(params)); + } +} + +std::string cmCPackInnoSetupGenerator::Quote(const std::string& string) +{ + if (cmHasPrefix(string, '"') && cmHasSuffix(string, '"')) { + return Quote(string.substr(1, string.length() - 2)); + } + + // Double quote syntax + std::string nString = string; + cmSystemTools::ReplaceString(nString, "\"", "\"\""); + return cmStrCat('"', nString, '"'); +} + +std::string cmCPackInnoSetupGenerator::QuotePath(const std::string& path) +{ + return Quote(cmSystemTools::ConvertToWindowsOutputPath(path)); +} + +std::string cmCPackInnoSetupGenerator::PrepareForConstant( + const std::string& string) +{ + std::string nString = string; + + cmSystemTools::ReplaceString(nString, "%", "%25"); // First replacement! + cmSystemTools::ReplaceString(nString, "\"", "%22"); + cmSystemTools::ReplaceString(nString, ",", "%2c"); + cmSystemTools::ReplaceString(nString, "|", "%7c"); + cmSystemTools::ReplaceString(nString, "}", "%7d"); + + return nString; +} diff --git a/Source/CPack/cmCPackInnoSetupGenerator.h b/Source/CPack/cmCPackInnoSetupGenerator.h new file mode 100644 index 0000000..342f227 --- /dev/null +++ b/Source/CPack/cmCPackInnoSetupGenerator.h @@ -0,0 +1,116 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying +file Copyright.txt or https://cmake.org/licensing for details. */ + +#pragma once + +#include <map> +#include <string> +#include <vector> + +#include "cmCPackGenerator.h" +#include "cmValue.h" + +using cmCPackInnoSetupKeyValuePairs = std::map<std::string, std::string>; + +class cmCPackComponentGroup; +class cmCPackComponent; + +/** \class cmCPackInnoSetupGenerator + * \brief A generator for Inno Setup + * + * https://jrsoftware.org/isinfo.php + */ +class cmCPackInnoSetupGenerator : public cmCPackGenerator +{ +public: + cmCPackTypeMacro(cmCPackInnoSetupGenerator, cmCPackGenerator); + + /** + * Construct generator + */ + cmCPackInnoSetupGenerator(); + ~cmCPackInnoSetupGenerator() override; + + static bool CanGenerate(); + +protected: + int InitializeInternal() override; + int PackageFiles() override; + + inline const char* GetOutputExtension() override { return ".exe"; } + + inline cmCPackGenerator::CPackSetDestdirSupport SupportsSetDestdir() + const override + { + return cmCPackGenerator::SETDESTDIR_UNSUPPORTED; + } + + inline bool SupportsAbsoluteDestination() const override { return false; } + inline bool SupportsComponentInstallation() const override { return true; } + +private: + bool ProcessSetupSection(); + bool ProcessFiles(); + bool ProcessComponents(); + + bool ConfigureISScript(); + bool Compile(); + + bool BuildDownloadedComponentArchive(cmCPackComponent* component, + const std::string& uploadDirectory, + std::string* hash); + + /** + * Returns the option's value or an empty string if the option isn't set. + */ + cmValue RequireOption(const std::string& key); + + std::string CustomComponentInstallDirectory( + const cmCPackComponent* component); + + /** + * Translates boolean expressions into "yes" or "no", as required in + * Inno Setup (only if "CPACK_INNOSETUP_USE_CMAKE_BOOL_FORMAT" is on). + */ + std::string TranslateBool(const std::string& value); + + /** + * Creates a typical line of key and value pairs using the given map. + * + * (e.g.: Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; + * GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked) + */ + std::string ISKeyValueLine(const cmCPackInnoSetupKeyValuePairs& params); + + std::string CreateRecursiveComponentPath(cmCPackComponentGroup* group, + const std::string& path = ""); + + void CreateRecursiveComponentGroups(cmCPackComponentGroup* group); + + /** + * These functions add quotes if the given value hasn't already quotes. + * Paths are converted into the format used by Windows before. + */ + std::string Quote(const std::string& string); + std::string QuotePath(const std::string& path); + + /** + * This function replaces the following 5 characters with their %-encoding: + * '|' '}' ',' '%' '"' + * Required for Inno Setup constants like {cm:...} + */ + std::string PrepareForConstant(const std::string& string); + + std::vector<std::string> includeDirectives; + cmCPackInnoSetupKeyValuePairs setupDirectives; + bool toplevelProgramFolder; + std::vector<std::string> languageInstructions; + std::vector<std::string> fileInstructions; + std::vector<std::string> dirInstructions; + std::vector<std::string> typeInstructions; + std::vector<std::string> componentInstructions; + std::vector<std::string> iconInstructions; + std::vector<std::string> desktopIconComponents; + std::vector<std::string> runInstructions; + std::vector<std::string> codeIncludes; +}; diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index 38a9d59..7749b29 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -246,8 +246,7 @@ int cmCPackNSISGenerator::PackageFiles() std::string nsisPreArguments; if (cmValue nsisArguments = this->GetOption("CPACK_NSIS_EXECUTABLE_PRE_ARGUMENTS")) { - std::vector<std::string> expandedArguments; - cmExpandList(nsisArguments, expandedArguments); + cmList expandedArguments{ nsisArguments }; for (auto& arg : expandedArguments) { if (!cmHasPrefix(arg, NSIS_OPT)) { @@ -260,8 +259,7 @@ int cmCPackNSISGenerator::PackageFiles() std::string nsisPostArguments; if (cmValue nsisArguments = this->GetOption("CPACK_NSIS_EXECUTABLE_POST_ARGUMENTS")) { - std::vector<std::string> expandedArguments; - cmExpandList(nsisArguments, expandedArguments); + cmList expandedArguments{ nsisArguments }; for (auto& arg : expandedArguments) { if (!cmHasPrefix(arg, NSIS_OPT)) { nsisPostArguments = cmStrCat(nsisPostArguments, NSIS_OPT); @@ -546,14 +544,14 @@ int cmCPackNSISGenerator::InitializeInternal() this->GetOption("CPACK_CREATE_DESKTOP_LINKS"); cmValue cpackNsisExecutablesDirectory = this->GetOption("CPACK_NSIS_EXECUTABLES_DIRECTORY"); - std::vector<std::string> cpackPackageDesktopLinksVector; + cmList cpackPackageDesktopLinksList; if (cpackPackageDeskTopLinks) { cmCPackLogger(cmCPackLog::LOG_DEBUG, "CPACK_CREATE_DESKTOP_LINKS: " << cpackPackageDeskTopLinks << std::endl); - cmExpandList(cpackPackageDeskTopLinks, cpackPackageDesktopLinksVector); - for (std::string const& cpdl : cpackPackageDesktopLinksVector) { + cpackPackageDesktopLinksList.assign(cpackPackageDeskTopLinks); + for (std::string const& cpdl : cpackPackageDesktopLinksList) { cmCPackLogger(cmCPackLog::LOG_DEBUG, "CPACK_CREATE_DESKTOP_LINKS: " << cpdl << std::endl); } @@ -592,7 +590,7 @@ int cmCPackNSISGenerator::InitializeInternal() << ".lnk\"" << std::endl; // see if CPACK_CREATE_DESKTOP_LINK_ExeName is on // if so add a desktop link - if (cm::contains(cpackPackageDesktopLinksVector, execName)) { + if (cm::contains(cpackPackageDesktopLinksList, execName)) { str << " StrCmp \"$INSTALL_DESKTOP\" \"1\" 0 +2\n"; str << " CreateShortCut \"$DESKTOP\\" << linkName << R"(.lnk" "$INSTDIR\)" << cpackNsisExecutablesDirectory << "\\" diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index c6387ab..882b579 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -17,6 +17,7 @@ #include "cmDuration.h" #include "cmFileTimeCache.h" #include "cmGeneratedFileStream.h" +#include "cmList.h" #include "cmMakefile.h" #include "cmProcessOutput.h" #include "cmStringAlgorithms.h" diff --git a/Source/CTest/cmCTestConfigureCommand.cxx b/Source/CTest/cmCTestConfigureCommand.cxx index 1f3633d..bae1f54 100644 --- a/Source/CTest/cmCTestConfigureCommand.cxx +++ b/Source/CTest/cmCTestConfigureCommand.cxx @@ -4,13 +4,13 @@ #include <cstring> #include <sstream> -#include <vector> #include <cmext/string_view> #include "cmCTest.h" #include "cmCTestConfigureHandler.h" #include "cmGlobalGenerator.h" +#include "cmList.h" #include "cmMakefile.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" @@ -25,10 +25,10 @@ void cmCTestConfigureCommand::BindArguments() cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() { - std::vector<std::string> options; + cmList options; if (!this->Options.empty()) { - cmExpandList(this->Options, options); + options.assign(this->Options); } if (this->CTest->GetCTestConfiguration("BuildDirectory").empty()) { diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 3adf33e..3a1cb64 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -2204,9 +2204,8 @@ bool cmCTestTestHandler::SetTestsProperties( for (cmCTestTestProperties& rt : this->TestList) { if (t == rt.Name) { if (key == "_BACKTRACE_TRIPLES"_s) { - std::vector<std::string> triples; // allow empty args in the triples - cmExpandList(val, triples, true); + cmList triples{ val, cmList::EmptyElements::Yes }; // Ensure we have complete triples otherwise the data is corrupt. if (triples.size() % 3 == 0) { @@ -2215,7 +2214,7 @@ bool cmCTestTestHandler::SetTestsProperties( // the first entry represents the top of the trace so we need to // reconstruct the backtrace in reverse - for (size_t i = triples.size(); i >= 3; i -= 3) { + for (auto i = triples.size(); i >= 3; i -= 3) { cmListFileContext fc; fc.FilePath = triples[i - 3]; long line = 0; diff --git a/Source/cmCMakeHostSystemInformationCommand.cxx b/Source/cmCMakeHostSystemInformationCommand.cxx index 58129a0..8bfd7c8 100644 --- a/Source/cmCMakeHostSystemInformationCommand.cxx +++ b/Source/cmCMakeHostSystemInformationCommand.cxx @@ -21,10 +21,12 @@ #include "cmArgumentParser.h" #include "cmExecutionStatus.h" +#include "cmList.h" #include "cmMakefile.h" #include "cmRange.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" +#include "cmValue.h" #include "cmWindowsRegistry.h" #ifdef _WIN32 @@ -303,7 +305,8 @@ std::map<std::string, std::string> GetOSReleaseVariables( } // 2. User provided (append to the CMake prvided) - makefile.GetDefExpandList("CMAKE_GET_OS_RELEASE_FALLBACK_SCRIPTS", scripts); + cmList::append( + scripts, makefile.GetDefinition("CMAKE_GET_OS_RELEASE_FALLBACK_SCRIPTS")); // Filter out files that are not in format `NNN-name.cmake` auto checkName = [](std::string const& filepath) -> bool { @@ -330,11 +333,11 @@ std::map<std::string, std::string> GetOSReleaseVariables( }); // Name of the variable to put the results - auto const result_variable = "CMAKE_GET_OS_RELEASE_FALLBACK_RESULT"_s; + std::string const result_variable{ "CMAKE_GET_OS_RELEASE_FALLBACK_RESULT" }; for (auto const& script : scripts) { // Unset the result variable - makefile.RemoveDefinition(result_variable.data()); + makefile.RemoveDefinition(result_variable); // include FATAL_ERROR and ERROR in the return status if (!makefile.ReadListFile(script) || @@ -343,8 +346,8 @@ std::map<std::string, std::string> GetOSReleaseVariables( continue; } - std::vector<std::string> variables; - if (!makefile.GetDefExpandList(result_variable.data(), variables)) { + cmList variables{ makefile.GetDefinition(result_variable) }; + if (variables.empty()) { // Heh, this script didn't found anything... go try the next one. continue; } @@ -370,7 +373,7 @@ std::map<std::string, std::string> GetOSReleaseVariables( } } - makefile.RemoveDefinition(result_variable.data()); + makefile.RemoveDefinition(result_variable); return data; } diff --git a/Source/cmCMakePathCommand.cxx b/Source/cmCMakePathCommand.cxx index 7755082..0c8f537 100644 --- a/Source/cmCMakePathCommand.cxx +++ b/Source/cmCMakePathCommand.cxx @@ -18,6 +18,7 @@ #include "cmArgumentParserTypes.h" #include "cmCMakePath.h" #include "cmExecutionStatus.h" +#include "cmList.h" #include "cmMakefile.h" #include "cmRange.h" #include "cmStringAlgorithms.h" @@ -626,12 +627,12 @@ bool HandleConvertCommand(std::vector<std::string> const& args, return false; } - std::vector<std::string> paths; + cmList paths; if (action == cmakePath) { paths = cmSystemTools::SplitString(args[1], pathSep.front()); } else { - cmExpandList(args[1], paths); + paths.assign(args[1]); } for (auto& path : paths) { @@ -648,7 +649,7 @@ bool HandleConvertCommand(std::vector<std::string> const& args, } } - auto value = cmJoin(paths, action == cmakePath ? ";"_s : pathSep); + auto value = action == cmakePath ? paths.to_string() : paths.join(pathSep); status.GetMakefile().AddDefinition(args[3], value); return true; diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index c763cc6..a311041 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -3099,8 +3099,7 @@ void cmCTest::PopulateCustomVector(cmMakefile* mf, const std::string& def, } cmCTestLog(this, DEBUG, "PopulateCustomVector: " << def << std::endl); - vec.clear(); - cmExpandList(*dval, vec); + cmList::assign(vec, *dval); for (std::string const& it : vec) { cmCTestLog(this, DEBUG, " -- " << it << std::endl); diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 6a5b4cc..5d44a6a 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -1917,19 +1917,18 @@ void cmComputeLinkInformation::DropDirectoryItem(BT<std::string> const& item) void cmComputeLinkInformation::ComputeFrameworkInfo() { // Avoid adding implicit framework paths. - std::vector<std::string> implicitDirVec; + cmList implicitDirs; // Get platform-wide implicit directories. - this->Makefile->GetDefExpandList( - "CMAKE_PLATFORM_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES", implicitDirVec); + implicitDirs.assign(this->Makefile->GetDefinition( + "CMAKE_PLATFORM_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES")); // Get language-specific implicit directories. std::string implicitDirVar = cmStrCat( "CMAKE_", this->LinkLanguage, "_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES"); - this->Makefile->GetDefExpandList(implicitDirVar, implicitDirVec); + implicitDirs.append(this->Makefile->GetDefinition(implicitDirVar)); - this->FrameworkPathsEmitted.insert(implicitDirVec.begin(), - implicitDirVec.end()); + this->FrameworkPathsEmitted.insert(implicitDirs.begin(), implicitDirs.end()); } void cmComputeLinkInformation::AddFrameworkPath(std::string const& p) @@ -2139,17 +2138,15 @@ void cmComputeLinkInformation::PrintLinkPolicyDiagnosis(std::ostream& os) void cmComputeLinkInformation::LoadImplicitLinkInfo() { - std::vector<std::string> implicitDirVec; - // Get platform-wide implicit directories. - this->Makefile->GetDefExpandList("CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES", - implicitDirVec); + cmList implicitDirs{ this->Makefile->GetDefinition( + "CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES") }; // Append library architecture to all implicit platform directories // and add them to the set if (cmValue libraryArch = this->Makefile->GetDefinition("CMAKE_LIBRARY_ARCHITECTURE")) { - for (std::string const& i : implicitDirVec) { + for (auto const& i : implicitDirs) { this->ImplicitLinkDirs.insert(cmStrCat(i, '/', *libraryArch)); } } @@ -2157,19 +2154,18 @@ void cmComputeLinkInformation::LoadImplicitLinkInfo() // Get language-specific implicit directories. std::string implicitDirVar = cmStrCat("CMAKE_", this->LinkLanguage, "_IMPLICIT_LINK_DIRECTORIES"); - this->Makefile->GetDefExpandList(implicitDirVar, implicitDirVec); + implicitDirs.append(this->Makefile->GetDefinition(implicitDirVar)); // Store implicit link directories. - this->ImplicitLinkDirs.insert(implicitDirVec.begin(), implicitDirVec.end()); + this->ImplicitLinkDirs.insert(implicitDirs.begin(), implicitDirs.end()); // Get language-specific implicit libraries. - std::vector<std::string> implicitLibVec; std::string implicitLibVar = cmStrCat("CMAKE_", this->LinkLanguage, "_IMPLICIT_LINK_LIBRARIES"); - this->Makefile->GetDefExpandList(implicitLibVar, implicitLibVec); + cmList implicitLibs{ this->Makefile->GetDefinition(implicitLibVar) }; // Store implicit link libraries. - for (std::string const& item : implicitLibVec) { + for (auto const& item : implicitLibs) { // Items starting in '-' but not '-l' are flags, not libraries, // and should not be filtered by this implicit list. if (item[0] != '-' || item[1] == 'l') { @@ -2178,8 +2174,8 @@ void cmComputeLinkInformation::LoadImplicitLinkInfo() } // Get platform specific rpath link directories - this->Makefile->GetDefExpandList("CMAKE_PLATFORM_RUNTIME_PATH", - this->RuntimeLinkDirs); + cmList::append(this->RuntimeLinkDirs, + this->Makefile->GetDefinition("CMAKE_PLATFORM_RUNTIME_PATH")); } std::vector<std::string> const& diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 02ee9e2..7d4ab50 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -126,7 +126,7 @@ ArgumentParser::Continue TryCompileLangProp(Arguments& args, ArgumentParser::Continue TryCompileCompileDefs(Arguments& args, cm::string_view val) { - cmExpandList(val, args.CompileDefs); + args.CompileDefs.append(val); return ArgumentParser::Continue::Yes; } @@ -789,7 +789,7 @@ cm::optional<cmTryCompileResult> cmCoreTryCompile::TryCompileCode( if (!arguments.CompileDefs.empty()) { // Pass using bracket arguments to preserve content. fprintf(fout, "add_definitions([==[%s]==])\n", - cmJoin(arguments.CompileDefs, "]==] [==[").c_str()); + arguments.CompileDefs.join("]==] [==[").c_str()); } if (!targets.empty()) { diff --git a/Source/cmCoreTryCompile.h b/Source/cmCoreTryCompile.h index ba38c19..c185c68 100644 --- a/Source/cmCoreTryCompile.h +++ b/Source/cmCoreTryCompile.h @@ -12,6 +12,7 @@ #include "cmArgumentParser.h" #include "cmArgumentParserTypes.h" +#include "cmList.h" #include "cmStateTypes.h" class cmConfigureLog; @@ -65,7 +66,7 @@ public: ArgumentParser::MaybeEmpty<std::vector<std::string>> CMakeFlags{ 1, "CMAKE_FLAGS" }; // fake argv[0] - std::vector<std::string> CompileDefs; + cmList CompileDefs; cm::optional<ArgumentParser::MaybeEmpty<std::vector<std::string>>> LinkLibraries; ArgumentParser::MaybeEmpty<std::vector<std::string>> LinkOptions; diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx index eca1abd..04bccce 100644 --- a/Source/cmDepends.cxx +++ b/Source/cmDepends.cxx @@ -9,6 +9,7 @@ #include "cmFileTime.h" #include "cmFileTimeCache.h" #include "cmGeneratedFileStream.h" +#include "cmList.h" #include "cmLocalUnixMakefileGenerator3.h" #include "cmMakefile.h" #include "cmStringAlgorithms.h" @@ -28,11 +29,11 @@ bool cmDepends::Write(std::ostream& makeDepends, std::ostream& internalDepends) std::map<std::string, std::set<std::string>> dependencies; { // Lookup the set of sources to scan. - std::vector<std::string> pairs; + cmList pairs; { std::string const srcLang = "CMAKE_DEPENDS_CHECK_" + this->Language; cmMakefile* mf = this->LocalGenerator->GetMakefile(); - cmExpandList(mf->GetSafeDefinition(srcLang), pairs); + pairs.assign(mf->GetSafeDefinition(srcLang)); } for (auto si = pairs.begin(); si != pairs.end();) { // Get the source and object file. diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx index 2527809..408a85b 100644 --- a/Source/cmDependsC.cxx +++ b/Source/cmDependsC.cxx @@ -8,6 +8,7 @@ #include "cmFileTime.h" #include "cmGlobalUnixMakefileGenerator3.h" +#include "cmList.h" #include "cmLocalUnixMakefileGenerator3.h" #include "cmMakefile.h" #include "cmStringAlgorithms.h" @@ -393,10 +394,10 @@ void cmDependsC::Scan(std::istream& is, const std::string& directory, void cmDependsC::SetupTransforms() { // Get the transformation rules. - std::vector<std::string> transformRules; cmMakefile* mf = this->LocalGenerator->GetMakefile(); - mf->GetDefExpandList("CMAKE_INCLUDE_TRANSFORMS", transformRules, true); - for (std::string const& tr : transformRules) { + cmList transformRules{ mf->GetDefinition("CMAKE_INCLUDE_TRANSFORMS"), + cmList::EmptyElements::Yes }; + for (auto const& tr : transformRules) { this->ParseTransform(tr); } diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index 718097f..aede3fe 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -13,6 +13,7 @@ #include "cmFortranParser.h" /* Interface to parser object. */ #include "cmGeneratedFileStream.h" #include "cmGlobalUnixMakefileGenerator3.h" +#include "cmList.h" #include "cmLocalUnixMakefileGenerator3.h" #include "cmMakefile.h" #include "cmOutputConverter.h" @@ -78,9 +79,8 @@ cmDependsFortran::cmDependsFortran(cmLocalUnixMakefileGenerator3* lg) this->SetIncludePathFromLanguage("Fortran"); // Get the list of definitions. - std::vector<std::string> definitions; cmMakefile* mf = this->LocalGenerator->GetMakefile(); - mf->GetDefExpandList("CMAKE_TARGET_DEFINITIONS_Fortran", definitions); + cmList definitions{ mf->GetDefinition("CMAKE_TARGET_DEFINITIONS_Fortran") }; // translate i.e. FOO=BAR to FOO and add it to the list of defined // preprocessor symbols @@ -244,9 +244,9 @@ bool cmDependsFortran::LocateModules() // Load information about other targets. cmMakefile* mf = this->LocalGenerator->GetMakefile(); - std::vector<std::string> infoFiles; - mf->GetDefExpandList("CMAKE_Fortran_TARGET_LINKED_INFO_FILES", infoFiles); - for (std::string const& i : infoFiles) { + cmList infoFiles{ mf->GetDefinition( + "CMAKE_Fortran_TARGET_LINKED_INFO_FILES") }; + for (auto const& i : infoFiles) { std::string targetDir = cmSystemTools::GetFilenamePath(i); std::string fname = targetDir + "/fortran.internal"; cmsys::ifstream fin(fname.c_str()); diff --git a/Source/cmEvaluatedTargetProperty.cxx b/Source/cmEvaluatedTargetProperty.cxx index 1173690..b82c29b 100644 --- a/Source/cmEvaluatedTargetProperty.cxx +++ b/Source/cmEvaluatedTargetProperty.cxx @@ -8,7 +8,7 @@ #include "cmGeneratorExpressionContext.h" #include "cmGeneratorTarget.h" #include "cmLinkItem.h" -#include "cmStringAlgorithms.h" +#include "cmList.h" struct cmGeneratorExpressionDAGChecker; diff --git a/Source/cmFileAPIToolchains.cxx b/Source/cmFileAPIToolchains.cxx index fe2972f..a51ae20 100644 --- a/Source/cmFileAPIToolchains.cxx +++ b/Source/cmFileAPIToolchains.cxx @@ -10,6 +10,7 @@ #include "cmFileAPI.h" #include "cmGlobalGenerator.h" +#include "cmList.h" #include "cmMakefile.h" #include "cmState.h" #include "cmStringAlgorithms.h" @@ -124,10 +125,11 @@ void Toolchains::DumpToolchainVariable(cmMakefile const* mf, cmStrCat("CMAKE_", lang, "_", variable.VariableSuffix); if (variable.IsList) { - std::vector<std::string> values; - if (mf->GetDefExpandList(variableName, values)) { + cmValue data = mf->GetDefinition(variableName); + if (data) { + cmList values(data); Json::Value jsonArray = Json::arrayValue; - for (std::string const& value : values) { + for (auto const& value : values) { jsonArray.append(value); } object[variable.ObjectKey] = jsonArray; diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx index c3fb907..bec6369 100644 --- a/Source/cmFindCommon.cxx +++ b/Source/cmFindCommon.cxx @@ -9,6 +9,7 @@ #include <cmext/algorithm> #include "cmExecutionStatus.h" +#include "cmList.h" #include "cmMakefile.h" #include "cmMessageType.h" #include "cmPolicies.h" @@ -238,9 +239,9 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths) } // Construct the list of path roots with no trailing slashes. - std::vector<std::string> roots; + cmList roots; if (rootPath) { - cmExpandList(*rootPath, roots); + roots.assign(*rootPath); } if (sysrootCompile) { roots.emplace_back(*sysrootCompile); @@ -251,14 +252,14 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths) if (sysroot) { roots.emplace_back(*sysroot); } - for (std::string& r : roots) { + for (auto& r : roots) { cmSystemTools::ConvertToUnixSlashes(r); } cmValue stagePrefix = this->Makefile->GetDefinition("CMAKE_STAGING_PREFIX"); // Copy the original set of unrooted paths. - std::vector<std::string> unrootedPaths = paths; + auto unrootedPaths = paths; paths.clear(); auto isSameDirectoryOrSubDirectory = [](std::string const& l, @@ -267,8 +268,8 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths) cmSystemTools::IsSubDirectory(l, r); }; - for (std::string const& r : roots) { - for (std::string const& up : unrootedPaths) { + for (auto const& r : roots) { + for (auto const& up : unrootedPaths) { // Place the unrooted path under the current root if it is not // already inside. Skip the unrooted path if it is relative to // a user home directory or is empty. @@ -308,7 +309,7 @@ void cmFindCommon::GetIgnoredPaths(std::vector<std::string>& ignore) // Construct the list of path roots with no trailing slashes. for (const char* pathName : paths) { // Get the list of paths to ignore from the variable. - this->Makefile->GetDefExpandList(pathName, ignore); + cmList::append(ignore, this->Makefile->GetDefinition(pathName)); } for (std::string& i : ignore) { @@ -333,7 +334,7 @@ void cmFindCommon::GetIgnoredPrefixPaths(std::vector<std::string>& ignore) // Construct the list of path roots with no trailing slashes. for (const char* pathName : paths) { // Get the list of paths to ignore from the variable. - this->Makefile->GetDefExpandList(pathName, ignore); + cmList::append(ignore, this->Makefile->GetDefinition(pathName)); } for (std::string& i : ignore) { diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx index 6296a60..9eb0603 100644 --- a/Source/cmFindLibraryCommand.cxx +++ b/Source/cmFindLibraryCommand.cxx @@ -11,6 +11,7 @@ #include "cmsys/RegularExpression.hxx" #include "cmGlobalGenerator.h" +#include "cmList.h" #include "cmMakefile.h" #include "cmState.h" #include "cmStateTypes.h" @@ -196,8 +197,8 @@ struct cmFindLibraryHelper cmGlobalGenerator* GG; // List of valid prefixes and suffixes. - std::vector<std::string> Prefixes; - std::vector<std::string> Suffixes; + cmList Prefixes; + cmList Suffixes; std::string PrefixRegexStr; std::string SuffixRegexStr; @@ -223,7 +224,7 @@ struct cmFindLibraryHelper std::string TestPath; void RegexFromLiteral(std::string& out, std::string const& in); - void RegexFromList(std::string& out, std::vector<std::string> const& in); + void RegexFromList(std::string& out, cmList const& in); size_type GetPrefixIndex(std::string const& prefix) { return std::find(this->Prefixes.begin(), this->Prefixes.end(), prefix) - @@ -307,8 +308,8 @@ cmFindLibraryHelper::cmFindLibraryHelper(std::string debugName, cmMakefile* mf, std::string const& prefixes_list = get_prefixes(this->Makefile); std::string const& suffixes_list = get_suffixes(this->Makefile); - cmExpandList(prefixes_list, this->Prefixes, true); - cmExpandList(suffixes_list, this->Suffixes, true); + this->Prefixes.assign(prefixes_list, cmList::EmptyElements::Yes); + this->Suffixes.assign(suffixes_list, cmList::EmptyElements::Yes); this->RegexFromList(this->PrefixRegexStr, this->Prefixes); this->RegexFromList(this->SuffixRegexStr, this->Suffixes); @@ -334,14 +335,13 @@ void cmFindLibraryHelper::RegexFromLiteral(std::string& out, } } -void cmFindLibraryHelper::RegexFromList(std::string& out, - std::vector<std::string> const& in) +void cmFindLibraryHelper::RegexFromList(std::string& out, cmList const& in) { // Surround the list in parens so the '|' does not apply to anything // else and the result can be checked after matching. out += "("; const char* sep = ""; - for (std::string const& s : in) { + for (auto const& s : in) { // Separate from previous item. out += sep; sep = "|"; diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 656703c..98b085c 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -1782,28 +1782,20 @@ bool cmFindPackageCommand::ReadListFile(const std::string& f, void cmFindPackageCommand::AppendToFoundProperty(const bool found) { - std::vector<std::string> foundContents; + cmList foundContents; cmValue foundProp = this->Makefile->GetState()->GetGlobalProperty("PACKAGES_FOUND"); - if (cmNonempty(foundProp)) { - cmExpandList(*foundProp, foundContents, false); - auto nameIt = - std::find(foundContents.begin(), foundContents.end(), this->Name); - if (nameIt != foundContents.end()) { - foundContents.erase(nameIt); - } + if (!foundProp.IsEmpty()) { + foundContents.assign(*foundProp); + foundContents.remove_items({ this->Name }); } - std::vector<std::string> notFoundContents; + cmList notFoundContents; cmValue notFoundProp = this->Makefile->GetState()->GetGlobalProperty("PACKAGES_NOT_FOUND"); - if (cmNonempty(notFoundProp)) { - cmExpandList(*notFoundProp, notFoundContents, false); - auto nameIt = - std::find(notFoundContents.begin(), notFoundContents.end(), this->Name); - if (nameIt != notFoundContents.end()) { - notFoundContents.erase(nameIt); - } + if (!notFoundProp.IsEmpty()) { + notFoundContents.assign(*notFoundProp); + notFoundContents.remove_items({ this->Name }); } if (found) { @@ -1812,12 +1804,11 @@ void cmFindPackageCommand::AppendToFoundProperty(const bool found) notFoundContents.push_back(this->Name); } - std::string tmp = cmJoin(foundContents, ";"); - this->Makefile->GetState()->SetGlobalProperty("PACKAGES_FOUND", tmp.c_str()); + this->Makefile->GetState()->SetGlobalProperty( + "PACKAGES_FOUND", foundContents.to_string().c_str()); - tmp = cmJoin(notFoundContents, ";"); - this->Makefile->GetState()->SetGlobalProperty("PACKAGES_NOT_FOUND", - tmp.c_str()); + this->Makefile->GetState()->SetGlobalProperty( + "PACKAGES_NOT_FOUND", notFoundContents.to_string().c_str()); } void cmFindPackageCommand::AppendSuccessInformation() diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index 3465c23..21a140d 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -23,6 +23,7 @@ #include "cmExecutionStatus.h" #include "cmFunctionBlocker.h" +#include "cmList.h" #include "cmListFileCache.h" #include "cmMakefile.h" #include "cmMessageType.h" @@ -156,16 +157,16 @@ bool cmForEachFunctionBlocker::ReplayZipLists( auto& mf = inStatus.GetMakefile(); // Expand the list of list-variables into a list of lists of strings - std::vector<std::vector<std::string>> values; + std::vector<cmList> values; values.reserve(this->Args.size() - this->IterationVarsCount); // Also track the longest list size std::size_t maxItems = 0u; for (auto const& var : cmMakeRange(this->Args).advance(this->IterationVarsCount)) { - std::vector<std::string> items; + cmList items; auto const& value = mf.GetSafeDefinition(var); if (!value.empty()) { - cmExpandList(value, items, true); + items.assign(value, cmList::EmptyElements::Yes); } maxItems = std::max(maxItems, items.size()); values.emplace_back(std::move(items)); @@ -344,7 +345,7 @@ bool HandleInMode(std::vector<std::string> const& args, } else if (doing == DoingLists) { auto const& value = makefile.GetSafeDefinition(arg); if (!value.empty()) { - cmExpandList(value, fb->Args, true); + cmExpandList(value, fb->Args, cmList::EmptyElements::Yes); } } else if (doing == DoingItems || doing == DoingZipLists) { diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index c5ae31b..04decd2 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -14,6 +14,7 @@ #include "cmGeneratorExpressionEvaluator.h" #include "cmGeneratorExpressionLexer.h" #include "cmGeneratorExpressionParser.h" +#include "cmList.h" #include "cmLocalGenerator.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 9dcbc39..4f5a663 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -19,7 +19,6 @@ #include <cm/iterator> #include <cm/optional> #include <cm/string_view> -#include <cm/vector> #include <cmext/algorithm> #include <cmext/string_view> @@ -1157,12 +1156,17 @@ inline cmList GetList(std::string const& list) return list.empty() ? cmList{} : cmList{ list, cmList::EmptyElements::Yes }; } -bool GetNumericArgument(const std::string& arg, int& value) +bool GetNumericArgument(const std::string& arg, cmList::index_type& value) { try { std::size_t pos; - value = std::stoi(arg, &pos); + if (sizeof(cmList::index_type) == sizeof(long)) { + value = std::stol(arg, &pos); + } else { + value = std::stoll(arg, &pos); + } + if (pos != arg.length()) { // this is not a number return false; @@ -1176,7 +1180,7 @@ bool GetNumericArgument(const std::string& arg, int& value) bool GetNumericArguments( cmGeneratorExpressionContext* ctx, const GeneratorExpressionContent* cnt, - Arguments const& args, std::vector<int>& indexes, + Arguments const& args, std::vector<cmList::index_type>& indexes, cmList::ExpandElements expandElements = cmList::ExpandElements::No) { using IndexRange = cmRange<Arguments::const_iterator>; @@ -1188,7 +1192,7 @@ bool GetNumericArguments( } for (auto const& value : arguments) { - int index; + cmList::index_type index; if (!GetNumericArgument(value, index)) { reportError(ctx, cnt->GetOriginalExpression(), cmStrCat("index: \"", value, "\" is not a valid index")); @@ -1242,7 +1246,7 @@ static const struct ListNode : public cmGeneratorExpressionNode return std::string{}; } - std::vector<int> indexes; + std::vector<cmList::index_type> indexes; if (!GetNumericArguments(ctx, cnt, args.advance(1), indexes, cmList::ExpandElements::Yes)) { return std::string{}; @@ -1273,7 +1277,7 @@ static const struct ListNode : public cmGeneratorExpressionNode if (CheckListParameters(ctx, cnt, "SUBLIST"_s, args, 3)) { auto list = GetList(args.front()); if (!list.empty()) { - std::vector<int> indexes; + std::vector<cmList::index_type> indexes; if (!GetNumericArguments(ctx, cnt, args.advance(1), indexes)) { return std::string{}; } @@ -1322,7 +1326,7 @@ static const struct ListNode : public cmGeneratorExpressionNode false)) { auto list = args.front(); args.advance(1); - return cmList::append(args.begin(), args.end(), list); + return cmList::append(list, args.begin(), args.end()); } return std::string{}; } }, @@ -1334,7 +1338,7 @@ static const struct ListNode : public cmGeneratorExpressionNode false)) { auto list = args.front(); args.advance(1); - return cmList::prepend(args.begin(), args.end(), list); + return cmList::prepend(list, args.begin(), args.end()); } return std::string{}; } }, @@ -1344,7 +1348,7 @@ static const struct ListNode : public cmGeneratorExpressionNode Arguments& args) -> std::string { if (CheckListParametersEx(ctx, cnt, "INSERT"_s, args.size(), 3, false)) { - int index; + cmList::index_type index; if (!GetNumericArgument(args[1], index)) { reportError( ctx, cnt->GetOriginalExpression(), @@ -1419,7 +1423,7 @@ static const struct ListNode : public cmGeneratorExpressionNode if (CheckListParametersEx(ctx, cnt, "REMOVE_AT"_s, args.size(), 2, false)) { auto list = GetList(args.front()); - std::vector<int> indexes; + std::vector<cmList::index_type> indexes; if (!GetNumericArguments(ctx, cnt, args.advance(1), indexes, cmList::ExpandElements::Yes)) { return std::string{}; @@ -1575,7 +1579,7 @@ static const struct ListNode : public cmGeneratorExpressionNode while (!args.empty()) { cmList indexList{ args.front() }; for (auto const& index : indexList) { - int value; + cmList::index_type value; if (!GetNumericArgument(index, value)) { // this is not a number, stop processing @@ -2141,11 +2145,11 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode // This imported target has an appropriate location // for this (possibly mapped) config. // Check if there is a proper config mapping for the tested config. - std::vector<std::string> mappedConfigs; + cmList mappedConfigs; std::string mapProp = cmStrCat( "MAP_IMPORTED_CONFIG_", cmSystemTools::UpperCase(context->Config)); if (cmValue mapValue = context->CurrentTarget->GetProperty(mapProp)) { - cmExpandList(cmSystemTools::UpperCase(*mapValue), mappedConfigs); + mappedConfigs.assign(cmSystemTools::UpperCase(*mapValue)); for (auto const& param : parameters) { if (cm::contains(mappedConfigs, cmSystemTools::UpperCase(param))) { @@ -2456,8 +2460,7 @@ static const struct LinkLibraryNode : public cmGeneratorExpressionNode return std::string(); } - std::vector<std::string> list; - cmExpandLists(parameters.begin(), parameters.end(), list); + cmList list{ parameters.begin(), parameters.end() }; if (list.empty()) { reportError( context, content->GetOriginalExpression(), @@ -2542,8 +2545,7 @@ static const struct LinkGroupNode : public cmGeneratorExpressionNode return std::string(); } - std::vector<std::string> list; - cmExpandLists(parameters.begin(), parameters.end(), list); + cmList list{ parameters.begin(), parameters.end() }; if (list.empty()) { reportError( context, content->GetOriginalExpression(), @@ -2633,8 +2635,7 @@ static const struct DeviceLinkNode : public cmGeneratorExpressionNode } if (context->HeadTarget->IsDeviceLink()) { - std::vector<std::string> list; - cmExpandLists(parameters.begin(), parameters.end(), list); + cmList list{ parameters.begin(), parameters.end() }; const auto DL_BEGIN = "<DEVICE_LINK>"_s; const auto DL_END = "</DEVICE_LINK>"_s; cm::erase_if(list, [&](const std::string& item) { @@ -3045,14 +3046,14 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode } } - std::vector<std::string> objects; + cmList objects; if (gt->IsImported()) { cmValue loc = nullptr; cmValue imp = nullptr; std::string suffix; if (gt->Target->GetMappedConfig(context->Config, loc, imp, suffix)) { - cmExpandList(*loc, objects); + objects.assign(*loc); } context->HadContextSensitiveCondition = true; } else { @@ -3070,7 +3071,7 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode context->HadContextSensitiveCondition = true; } - for (std::string& o : objects) { + for (auto& o : objects) { o = cmStrCat(obj_dir, o); } } @@ -3190,7 +3191,7 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode } context->HadHeadSensitiveCondition = true; - using LangMap = std::map<std::string, std::vector<std::string>>; + using LangMap = std::map<std::string, cmList>; static LangMap availableFeatures; LangMap testedFeatures; @@ -3212,7 +3213,7 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode reportError(context, content->GetOriginalExpression(), error); return std::string(); } - cmExpandList(featuresKnown, availableFeatures[lang]); + availableFeatures[lang].assign(featuresKnown); } } diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index e7145b2..2eae245 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -770,14 +770,13 @@ void handleSystemIncludesDep(cmLocalGenerator* lg, const std::string& config, cmGeneratorTarget const* headTarget, cmGeneratorExpressionDAGChecker* dagChecker, - std::vector<std::string>& result, - bool excludeImported, std::string const& language) + cmList& result, bool excludeImported, + std::string const& language) { if (cmValue dirs = depTgt->GetProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES")) { - cmExpandList(cmGeneratorExpression::Evaluate(*dirs, lg, config, headTarget, - dagChecker, depTgt, language), - result); + result.append(cmGeneratorExpression::Evaluate( + *dirs, lg, config, headTarget, dagChecker, depTgt, language)); } if (!depTgt->GetPropertyAsBool("SYSTEM")) { return; @@ -792,9 +791,8 @@ void handleSystemIncludesDep(cmLocalGenerator* lg, } if (cmValue dirs = depTgt->GetProperty("INTERFACE_INCLUDE_DIRECTORIES")) { - cmExpandList(cmGeneratorExpression::Evaluate(*dirs, lg, config, headTarget, - dagChecker, depTgt, language), - result); + result.append(cmGeneratorExpression::Evaluate( + *dirs, lg, config, headTarget, dagChecker, depTgt, language)); } } } @@ -1288,12 +1286,11 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory( bool excludeImported = this->GetPropertyAsBool("NO_SYSTEM_FROM_IMPORTED"); - std::vector<std::string> result; + cmList result; for (std::string const& it : this->Target->GetSystemIncludeDirectories()) { - cmExpandList(cmGeneratorExpression::Evaluate(it, this->LocalGenerator, - config, this, &dagChecker, - nullptr, language), - result); + result.append(cmGeneratorExpression::Evaluate(it, this->LocalGenerator, + config, this, &dagChecker, + nullptr, language)); } std::vector<cmGeneratorTarget const*> const& deps = @@ -1776,10 +1773,8 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetSourceFilePaths( return files; } - std::vector<std::string> debugProperties; - this->Makefile->GetDefExpandList("CMAKE_DEBUG_TARGET_PROPERTIES", - debugProperties); - + cmList debugProperties{ this->Makefile->GetDefinition( + "CMAKE_DEBUG_TARGET_PROPERTIES") }; bool debugSources = !this->DebugSourcesDone && cm::contains(debugProperties, "SOURCES"); @@ -3323,9 +3318,9 @@ std::string cmGeneratorTarget::GetCompilePDBDirectory( std::vector<std::string> cmGeneratorTarget::GetAppleArchs( std::string const& config, cm::optional<std::string> lang) const { - std::vector<std::string> archVec; + cmList archList; if (!this->IsApple()) { - return archVec; + return std::move(archList.data()); } cmValue archs = nullptr; if (!config.empty()) { @@ -3337,17 +3332,18 @@ std::vector<std::string> cmGeneratorTarget::GetAppleArchs( archs = this->GetProperty("OSX_ARCHITECTURES"); } if (archs) { - cmExpandList(*archs, archVec); + archList.assign(*archs); } - if (archVec.empty() && + if (archList.empty() && // Fall back to a default architecture if no compiler target is set. (!lang || this->Makefile ->GetDefinition(cmStrCat("CMAKE_", *lang, "_COMPILER_TARGET")) .IsEmpty())) { - this->Makefile->GetDefExpandList("_CMAKE_APPLE_ARCHS_DEFAULT", archVec); + archList.assign( + this->Makefile->GetDefinition("_CMAKE_APPLE_ARCHS_DEFAULT")); } - return archVec; + return std::move(archList.data()); } void cmGeneratorTarget::AddExplicitLanguageFlags(std::string& flags, @@ -3456,10 +3452,9 @@ void cmGeneratorTarget::AddCUDAArchitectureFlags(cmBuildStep compileOrLink, std::vector<CudaArchitecture> architectures; { - std::vector<std::string> options; - cmExpandList(property, options); + cmList options(property); - for (std::string& option : options) { + for (auto& option : options) { CudaArchitecture architecture; // Architecture name is up to the first specifier. @@ -3550,8 +3545,7 @@ void cmGeneratorTarget::AddISPCTargetFlags(std::string& flags) const this->Makefile->GetSafeDefinition("CMAKE_ISPC_COMPILER_ID"); if (compiler == "Intel") { - std::vector<std::string> targets; - cmExpandList(property, targets); + cmList targets(property); if (!targets.empty()) { flags += cmStrCat(" --target=", cmWrap("", targets, "", ",")); } @@ -3573,8 +3567,7 @@ void cmGeneratorTarget::AddHIPArchitectureFlags(std::string& flags) const return; } - std::vector<std::string> options; - cmExpandList(property, options); + cmList options(property); for (std::string& option : options) { flags += " --offload-arch=" + option; @@ -3786,10 +3779,8 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetIncludeDirectories( cmGeneratorExpressionDAGChecker dagChecker(this, "INCLUDE_DIRECTORIES", nullptr, nullptr); - std::vector<std::string> debugProperties; - this->Makefile->GetDefExpandList("CMAKE_DEBUG_TARGET_PROPERTIES", - debugProperties); - + cmList debugProperties{ this->Makefile->GetDefinition( + "CMAKE_DEBUG_TARGET_PROPERTIES") }; bool debugIncludes = !this->DebugIncludesDone && cm::contains(debugProperties, "INCLUDE_DIRECTORIES"); @@ -4045,10 +4036,8 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileOptions( cmGeneratorExpressionDAGChecker dagChecker(this, "COMPILE_OPTIONS", nullptr, nullptr); - std::vector<std::string> debugProperties; - this->Makefile->GetDefExpandList("CMAKE_DEBUG_TARGET_PROPERTIES", - debugProperties); - + cmList debugProperties{ this->Makefile->GetDefinition( + "CMAKE_DEBUG_TARGET_PROPERTIES") }; bool debugOptions = !this->DebugCompileOptionsDone && cm::contains(debugProperties, "COMPILE_OPTIONS"); @@ -4088,10 +4077,8 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileFeatures( cmGeneratorExpressionDAGChecker dagChecker(this, "COMPILE_FEATURES", nullptr, nullptr); - std::vector<std::string> debugProperties; - this->Makefile->GetDefExpandList("CMAKE_DEBUG_TARGET_PROPERTIES", - debugProperties); - + cmList debugProperties{ this->Makefile->GetDefinition( + "CMAKE_DEBUG_TARGET_PROPERTIES") }; bool debugFeatures = !this->DebugCompileFeaturesDone && cm::contains(debugProperties, "COMPILE_FEATURES"); @@ -4140,10 +4127,8 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileDefinitions( cmGeneratorExpressionDAGChecker dagChecker(this, "COMPILE_DEFINITIONS", nullptr, nullptr); - std::vector<std::string> debugProperties; - this->Makefile->GetDefExpandList("CMAKE_DEBUG_TARGET_PROPERTIES", - debugProperties); - + cmList debugProperties{ this->Makefile->GetDefinition( + "CMAKE_DEBUG_TARGET_PROPERTIES") }; bool debugDefines = !this->DebugCompileDefinitionsDone && cm::contains(debugProperties, "COMPILE_DEFINITIONS"); @@ -4206,10 +4191,8 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetPrecompileHeaders( cmGeneratorExpressionDAGChecker dagChecker(this, "PRECOMPILE_HEADERS", nullptr, nullptr); - std::vector<std::string> debugProperties; - this->Makefile->GetDefExpandList("CMAKE_DEBUG_TARGET_PROPERTIES", - debugProperties); - + cmList debugProperties{ this->Makefile->GetDefinition( + "CMAKE_DEBUG_TARGET_PROPERTIES") }; bool debugDefines = !this->DebugPrecompileHeadersDone && std::find(debugProperties.begin(), debugProperties.end(), "PRECOMPILE_HEADERS") != debugProperties.end(); @@ -4603,10 +4586,8 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetLinkOptions( cmGeneratorExpressionDAGChecker dagChecker(this, "LINK_OPTIONS", nullptr, nullptr); - std::vector<std::string> debugProperties; - this->Makefile->GetDefExpandList("CMAKE_DEBUG_TARGET_PROPERTIES", - debugProperties); - + cmList debugProperties{ this->Makefile->GetDefinition( + "CMAKE_DEBUG_TARGET_PROPERTIES") }; bool debugOptions = !this->DebugLinkOptionsDone && cm::contains(debugProperties, "LINK_OPTIONS"); @@ -4887,10 +4868,8 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetLinkDirectories( cmGeneratorExpressionDAGChecker dagChecker(this, "LINK_DIRECTORIES", nullptr, nullptr); - std::vector<std::string> debugProperties; - this->Makefile->GetDefExpandList("CMAKE_DEBUG_TARGET_PROPERTIES", - debugProperties); - + cmList debugProperties{ this->Makefile->GetDefinition( + "CMAKE_DEBUG_TARGET_PROPERTIES") }; bool debugDirectories = !this->DebugLinkDirectoriesDone && cm::contains(debugProperties, "LINK_DIRECTORIES"); @@ -5667,8 +5646,7 @@ cmGeneratorTarget::GetCompatibleInterfaces(std::string const& config) const for (cmGeneratorTarget const* li : deps) { #define CM_READ_COMPATIBLE_INTERFACE(X, x) \ if (cmValue prop = li->GetProperty("COMPATIBLE_INTERFACE_" #X)) { \ - std::vector<std::string> props; \ - cmExpandList(*prop, props); \ + cmList props(*prop); \ compat.Props##x.insert(props.begin(), props.end()); \ } CM_READ_COMPATIBLE_INTERFACE(BOOL, Bool) @@ -6742,10 +6720,8 @@ void cmGeneratorTarget::ReportPropertyOrigin( const std::string& p, const std::string& result, const std::string& report, const std::string& compatibilityType) const { - std::vector<std::string> debugProperties; - this->Target->GetMakefile()->GetDefExpandList( - "CMAKE_DEBUG_TARGET_PROPERTIES", debugProperties); - + cmList debugProperties{ this->Target->GetMakefile()->GetDefinition( + "CMAKE_DEBUG_TARGET_PROPERTIES") }; bool debugOrigin = !this->DebugCompatiblePropertiesDone[p] && cm::contains(debugProperties, p); @@ -8246,7 +8222,6 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries( cmBTStringRange entryRange = this->Target->GetLinkImplementationEntries(); // Collect libraries directly linked in this configuration. for (auto const& entry : entryRange) { - std::vector<std::string> llibs; // Keep this logic in sync with ExpandLinkItems. cmGeneratorExpressionDAGChecker dagChecker(this, "LINK_LIBRARIES", nullptr, nullptr); @@ -8273,7 +8248,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries( cge->Evaluate(this->LocalGenerator, config, head, &dagChecker, nullptr, this->LinkerLanguage); bool const checkCMP0027 = evaluated != entry.Value; - cmExpandList(evaluated, llibs); + cmList llibs(evaluated); if (cge->GetHadHeadSensitiveCondition()) { impl.HadHeadSensitiveCondition = true; } @@ -8284,7 +8259,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries( impl.HadLinkLanguageSensitiveCondition = true; } - for (std::string const& lib : llibs) { + for (auto const& lib : llibs) { if (this->IsLinkLookupScope(lib, lg)) { continue; } @@ -8452,16 +8427,16 @@ bool cmGeneratorTarget::HasPackageReferences() const std::vector<std::string> cmGeneratorTarget::GetPackageReferences() const { - std::vector<std::string> packageReferences; + cmList packageReferences; if (this->IsInBuildSystem()) { if (cmValue vsPackageReferences = this->GetProperty("VS_PACKAGE_REFERENCES")) { - cmExpandList(*vsPackageReferences, packageReferences); + packageReferences.assign(*vsPackageReferences); } } - return packageReferences; + return std::move(packageReferences.data()); } std::string cmGeneratorTarget::GetPDBDirectory(const std::string& config) const diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index d0a0fdf..040f500 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -239,10 +239,10 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string& lang, this->GetCMakeInstance()->GetState()->GetInitializedCacheValue(langComp); // Split compiler from arguments - std::vector<std::string> cnameArgVec; + cmList cnameArgList; if (cname && !cname->empty()) { - cmExpandList(*cname, cnameArgVec); - cname = cmValue(cnameArgVec.front()); + cnameArgList.assign(*cname); + cname = cmValue(cnameArgList.front()); } std::string changeVars; @@ -1985,7 +1985,6 @@ void cmGlobalGenerator::CheckTargetProperties() notFoundMap[varName] = text; } } - std::vector<std::string> incs; cmValue incDirProp = target.second.GetProperty("INCLUDE_DIRECTORIES"); if (!incDirProp) { continue; @@ -1994,7 +1993,7 @@ void cmGlobalGenerator::CheckTargetProperties() std::string incDirs = cmGeneratorExpression::Preprocess( *incDirProp, cmGeneratorExpression::StripAllGeneratorExpressions); - cmExpandList(incDirs, incs); + cmList incs(incDirs); for (std::string const& incDir : incs) { if (incDir.size() > 9 && cmIsNOTFOUND(incDir)) { @@ -2789,11 +2788,9 @@ void cmGlobalGenerator::AddGlobalTarget_Test( cmCustomCommandLine singleLine; singleLine.push_back(cmSystemTools::GetCTestCommand()); singleLine.push_back("--force-new-ctest-process"); - std::vector<std::string> args; - if (mf->GetDefExpandList("CMAKE_CTEST_ARGUMENTS", args)) { - for (auto const& arg : args) { - singleLine.push_back(arg); - } + cmList args(mf->GetDefinition("CMAKE_CTEST_ARGUMENTS")); + for (auto const& arg : args) { + singleLine.push_back(arg); } if (cmNonempty(cmakeCfgIntDir) && cmakeCfgIntDir[0] != '.') { singleLine.push_back("-C"); @@ -3348,12 +3345,12 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target) cmSystemTools::MakeDirectory(dir); cmGeneratedFileStream fout(file); - std::vector<std::string> labels; + cmList labels; // List the target-wide labels. All sources in the target get // these labels. if (targetLabels) { - cmExpandList(*targetLabels, labels); + labels.assign(*targetLabels); if (!labels.empty()) { fout << "# Target labels\n"; for (std::string const& l : labels) { @@ -3364,27 +3361,27 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target) } // List directory labels - std::vector<std::string> directoryLabelsList; - std::vector<std::string> cmakeDirectoryLabelsList; + cmList directoryLabelsList; + cmList cmakeDirectoryLabelsList; if (directoryLabels) { - cmExpandList(*directoryLabels, directoryLabelsList); + directoryLabelsList.assign(*directoryLabels); } if (cmakeDirectoryLabels) { - cmExpandList(*cmakeDirectoryLabels, cmakeDirectoryLabelsList); + cmakeDirectoryLabelsList.assign(*cmakeDirectoryLabels); } if (!directoryLabelsList.empty() || !cmakeDirectoryLabelsList.empty()) { fout << "# Directory labels\n"; } - for (std::string const& li : directoryLabelsList) { + for (auto const& li : directoryLabelsList) { fout << " " << li << "\n"; lj_target_labels.append(li); } - for (std::string const& li : cmakeDirectoryLabelsList) { + for (auto const& li : cmakeDirectoryLabelsList) { fout << " " << li << "\n"; lj_target_labels.append(li); } @@ -3405,10 +3402,9 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target) fout << sfp << "\n"; lj_source["file"] = sfp; if (cmValue svalue = sf->GetProperty("LABELS")) { - labels.clear(); Json::Value& lj_source_labels = lj_source["labels"] = Json::arrayValue; - cmExpandList(*svalue, labels); - for (std::string const& label : labels) { + labels.assign(*svalue); + for (auto const& label : labels) { fout << " " << label << "\n"; lj_source_labels.append(label); } diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 0c28776..84c85e0 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -32,6 +32,7 @@ #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" #include "cmLinkLineComputer.h" +#include "cmList.h" #include "cmListFileCache.h" #include "cmLocalGenerator.h" #include "cmLocalNinjaGenerator.h" @@ -3031,19 +3032,17 @@ void cmGlobalNinjaMultiGenerator::GetQtAutoGenConfigs( bool cmGlobalNinjaMultiGenerator::InspectConfigTypeVariables() { - std::vector<std::string> configsVec; - cmExpandList( - this->Makefiles.front()->GetSafeDefinition("CMAKE_CONFIGURATION_TYPES"), - configsVec); - if (configsVec.empty()) { - configsVec.emplace_back(); + cmList configsList{ this->Makefiles.front()->GetDefinition( + "CMAKE_CONFIGURATION_TYPES") }; + if (configsList.empty()) { + configsList.emplace_back(); } - std::set<std::string> configs(configsVec.cbegin(), configsVec.cend()); + std::set<std::string> configs(configsList.cbegin(), configsList.cend()); this->DefaultFileConfig = this->Makefiles.front()->GetSafeDefinition("CMAKE_DEFAULT_BUILD_TYPE"); if (this->DefaultFileConfig.empty()) { - this->DefaultFileConfig = configsVec.front(); + this->DefaultFileConfig = configsList.front(); } if (!configs.count(this->DefaultFileConfig)) { std::ostringstream msg; @@ -3055,11 +3054,9 @@ bool cmGlobalNinjaMultiGenerator::InspectConfigTypeVariables() return false; } - std::vector<std::string> crossConfigsVec; - cmExpandList( - this->Makefiles.front()->GetSafeDefinition("CMAKE_CROSS_CONFIGS"), - crossConfigsVec); - auto crossConfigs = ListSubsetWithAll(configs, configs, crossConfigsVec); + cmList crossConfigsList{ this->Makefiles.front()->GetSafeDefinition( + "CMAKE_CROSS_CONFIGS") }; + auto crossConfigs = ListSubsetWithAll(configs, configs, crossConfigsList); if (!crossConfigs) { std::ostringstream msg; msg << "CMAKE_CROSS_CONFIGS is not a subset of " @@ -3086,12 +3083,11 @@ bool cmGlobalNinjaMultiGenerator::InspectConfigTypeVariables() return false; } - std::vector<std::string> defaultConfigsVec; - cmExpandList(defaultConfigsString, defaultConfigsVec); + cmList defaultConfigsList(defaultConfigsString); if (!this->DefaultFileConfig.empty()) { auto defaultConfigs = ListSubsetWithAll(this->GetCrossConfigs(this->DefaultFileConfig), - this->CrossConfigs, defaultConfigsVec); + this->CrossConfigs, defaultConfigsList); if (!defaultConfigs) { std::ostringstream msg; msg << "CMAKE_DEFAULT_CONFIGS is not a subset of CMAKE_CROSS_CONFIGS"; diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index de13924..bcb26cc 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -8,6 +8,7 @@ #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" #include "cmGlobalVisualStudioGenerator.h" +#include "cmList.h" #include "cmListFileCache.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" @@ -205,12 +206,12 @@ void cmGlobalVisualStudio71Generator::WriteProjectConfigurations( !platformMapping.empty() ? platformMapping : this->GetPlatformName(); std::string guid = this->GetGUID(name); for (std::string const& i : configs) { - std::vector<std::string> mapConfig; + cmList mapConfig; const char* dstConfig = i.c_str(); if (target.GetProperty("EXTERNAL_MSPROJECT")) { if (cmValue m = target.GetProperty("MAP_IMPORTED_CONFIG_" + cmSystemTools::UpperCase(i))) { - cmExpandList(*m, mapConfig); + mapConfig.assign(*m); if (!mapConfig.empty()) { dstConfig = mapConfig[0].c_str(); } diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index d902c68..819bb09 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -20,6 +20,7 @@ #include "cmGlobalGenerator.h" #include "cmGlobalVisualStudio7Generator.h" #include "cmGlobalVisualStudioGenerator.h" +#include "cmList.h" #include "cmListFileCache.h" #include "cmLocalGenerator.h" #include "cmLocalVisualStudio7Generator.h" @@ -411,12 +412,12 @@ void cmGlobalVisualStudio8Generator::WriteProjectConfigurations( { std::string guid = this->GetGUID(name); for (std::string const& i : configs) { - std::vector<std::string> mapConfig; + cmList mapConfig; const char* dstConfig = i.c_str(); if (target.GetProperty("EXTERNAL_MSPROJECT")) { if (cmValue m = target.GetProperty("MAP_IMPORTED_CONFIG_" + cmSystemTools::UpperCase(i))) { - cmExpandList(*m, mapConfig); + mapConfig.assign(*m); if (!mapConfig.empty()) { dstConfig = mapConfig[0].c_str(); } diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 1328f4b..60f46e5 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -4600,13 +4600,12 @@ std::string cmGlobalXCodeGenerator::GetTargetTempDir( void cmGlobalXCodeGenerator::ComputeArchitectures(cmMakefile* mf) { this->Architectures.clear(); - cmValue sysroot = mf->GetDefinition("CMAKE_OSX_SYSROOT"); - if (sysroot) { - mf->GetDefExpandList("CMAKE_OSX_ARCHITECTURES", this->Architectures); - } + cmList::append(this->Architectures, + mf->GetDefinition("CMAKE_OSX_ARCHITECTURES")); if (this->Architectures.empty()) { - mf->GetDefExpandList("_CMAKE_APPLE_ARCHS_DEFAULT", this->Architectures); + cmList::append(this->Architectures, + mf->GetDefinition("_CMAKE_APPLE_ARCHS_DEFAULT")); } if (this->Architectures.empty()) { diff --git a/Source/cmIDEOptions.cxx b/Source/cmIDEOptions.cxx index 9468d4a..f94faf8 100644 --- a/Source/cmIDEOptions.cxx +++ b/Source/cmIDEOptions.cxx @@ -12,6 +12,7 @@ #include "cmsys/String.h" #include "cmIDEFlagTable.h" +#include "cmList.h" #include "cmStringAlgorithms.h" cmIDEOptions::cmIDEOptions() diff --git a/Source/cmInstallDirectoryGenerator.cxx b/Source/cmInstallDirectoryGenerator.cxx index d358763..6aa9910 100644 --- a/Source/cmInstallDirectoryGenerator.cxx +++ b/Source/cmInstallDirectoryGenerator.cxx @@ -6,6 +6,7 @@ #include "cmGeneratorExpression.h" #include "cmInstallType.h" +#include "cmList.h" #include "cmListFileCache.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" @@ -53,17 +54,16 @@ bool cmInstallDirectoryGenerator::Compute(cmLocalGenerator* lg) std::vector<std::string> cmInstallDirectoryGenerator::GetDirectories( std::string const& config) const { - std::vector<std::string> directories; + cmList directories; if (this->ActionsPerConfig) { for (std::string const& f : this->Directories) { - cmExpandList( - cmGeneratorExpression::Evaluate(f, this->LocalGenerator, config), - directories); + directories.append( + cmGeneratorExpression::Evaluate(f, this->LocalGenerator, config)); } } else { directories = this->Directories; } - return directories; + return std::move(directories.data()); } void cmInstallDirectoryGenerator::GenerateScriptActions(std::ostream& os, diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx index 18a852b..43dc656 100644 --- a/Source/cmInstallFilesGenerator.cxx +++ b/Source/cmInstallFilesGenerator.cxx @@ -6,8 +6,8 @@ #include "cmGeneratorExpression.h" #include "cmInstallType.h" +#include "cmList.h" #include "cmListFileCache.h" -#include "cmStringAlgorithms.h" class cmLocalGenerator; @@ -69,17 +69,15 @@ std::string cmInstallFilesGenerator::GetRename(std::string const& config) const std::vector<std::string> cmInstallFilesGenerator::GetFiles( std::string const& config) const { - std::vector<std::string> files; if (this->ActionsPerConfig) { + cmList files; for (std::string const& f : this->Files) { - cmExpandList( - cmGeneratorExpression::Evaluate(f, this->LocalGenerator, config), - files); + files.append( + cmGeneratorExpression::Evaluate(f, this->LocalGenerator, config)); } - } else { - files = this->Files; + return std::move(files.data()); } - return files; + return this->Files; } void cmInstallFilesGenerator::AddFilesInstallRule( diff --git a/Source/cmInstalledFile.cxx b/Source/cmInstalledFile.cxx index 5bf8320..381c91b 100644 --- a/Source/cmInstalledFile.cxx +++ b/Source/cmInstalledFile.cxx @@ -5,9 +5,9 @@ #include <utility> #include "cmGeneratorExpression.h" +#include "cmList.h" #include "cmListFileCache.h" #include "cmMakefile.h" -#include "cmStringAlgorithms.h" #include "cmValue.h" cmInstalledFile::cmInstalledFile() = default; @@ -97,12 +97,11 @@ bool cmInstalledFile::GetPropertyAsBool(const std::string& prop) const return isSet && cmIsOn(value); } -void cmInstalledFile::GetPropertyAsList(const std::string& prop, - std::vector<std::string>& list) const +std::vector<std::string> cmInstalledFile::GetPropertyAsList( + const std::string& prop) const { std::string value; this->GetProperty(prop, value); - list.clear(); - cmExpandList(value, list); + return std::move(cmList(value).data()); } diff --git a/Source/cmInstalledFile.h b/Source/cmInstalledFile.h index 82474f5..373c349 100644 --- a/Source/cmInstalledFile.h +++ b/Source/cmInstalledFile.h @@ -59,8 +59,7 @@ public: bool GetPropertyAsBool(const std::string& prop) const; - void GetPropertyAsList(const std::string& prop, - std::vector<std::string>& list) const; + std::vector<std::string> GetPropertyAsList(const std::string& prop) const; void SetName(cmMakefile* mf, const std::string& name); diff --git a/Source/cmList.cxx b/Source/cmList.cxx index 2064afb..022fcd2 100644 --- a/Source/cmList.cxx +++ b/Source/cmList.cxx @@ -287,18 +287,20 @@ protected: : TransformSelector(std::move(tag)) { } - TransformSelectorIndexes(std::string&& tag, std::vector<int> const& indexes) + TransformSelectorIndexes(std::string&& tag, + std::vector<index_type> const& indexes) : TransformSelector(std::move(tag)) , Indexes(indexes) { } - TransformSelectorIndexes(std::string&& tag, std::vector<int>&& indexes) + TransformSelectorIndexes(std::string&& tag, + std::vector<index_type>&& indexes) : TransformSelector(std::move(tag)) , Indexes(indexes) { } - int NormalizeIndex(index_type index, std::size_t count) + index_type NormalizeIndex(index_type index, std::size_t count) { if (index < 0) { index = static_cast<index_type>(count) + index; @@ -338,7 +340,7 @@ public: class TransformSelectorFor : public TransformSelectorIndexes { public: - TransformSelectorFor(int start, int stop, int step) + TransformSelectorFor(index_type start, index_type stop, index_type step) : TransformSelectorIndexes("FOR") , Start(start) , Stop(stop) @@ -369,7 +371,7 @@ public: auto start = this->Start; auto step = this->Step; std::generate(this->Indexes.begin(), this->Indexes.end(), - [&start, step]() -> int { + [&start, step]() -> index_type { auto r = start; start += step; return r; @@ -805,7 +807,7 @@ std::string cmList::join(cm::string_view glue) const return cmJoin(this->Values, glue); } -std::string& cmList::append(cm::string_view value, std::string& list) +std::string& cmList::append(std::string& list, cm::string_view value) { if (list.empty()) { list = std::string(value); @@ -816,7 +818,7 @@ std::string& cmList::append(cm::string_view value, std::string& list) return list; } -std::string& cmList::prepend(cm::string_view value, std::string& list) +std::string& cmList::prepend(std::string& list, cm::string_view value) { if (list.empty()) { list = std::string(value); @@ -884,7 +886,7 @@ cmList cmList::GetItems(std::vector<index_type>&& indexes) const cmList listItems; for (auto index : indexes) { - listItems.emplace_back(this->at(index)); + listItems.emplace_back(this->get_item(index)); } return listItems; @@ -898,9 +900,10 @@ cmList& cmList::RemoveItems(std::vector<index_type>&& indexes) // compute all indexes std::vector<size_type> idx(indexes.size()); - std::transform( - indexes.cbegin(), indexes.cend(), idx.begin(), - [this](const index_type& index) { return this->ComputeIndex(index); }); + std::transform(indexes.cbegin(), indexes.cend(), idx.begin(), + [this](const index_type& index) -> size_type { + return this->ComputeIndex(index); + }); std::sort(idx.begin(), idx.end(), [](size_type l, size_type r) { return l > r; }); @@ -927,8 +930,8 @@ cmList& cmList::RemoveItems(std::vector<std::string>&& items) } cmList::container_type::iterator cmList::Insert( - container_type::const_iterator pos, std::string&& value, - container_type& container, ExpandElements expandElements, + container_type& container, container_type::const_iterator pos, + std::string&& value, ExpandElements expandElements, EmptyElements emptyElements) { auto delta = std::distance(container.cbegin(), pos); diff --git a/Source/cmList.h b/Source/cmList.h index 8a1cb8e..d9ce951 100644 --- a/Source/cmList.h +++ b/Source/cmList.h @@ -6,6 +6,7 @@ #include "cmConfigure.h" // IWYU pragma: keep #include <algorithm> +#include <cstdint> #include <initializer_list> #include <iterator> #include <memory> @@ -23,14 +24,18 @@ /** * CMake lists management + * A CMake list is a string where list elements are separated by the ';' + * character. * * For all operations, input arguments (single value like cm::string_view or * multiple values specified through pair of iterators) are, by default, * expanded. The expansion can be controlled by the cmList::ExpandElements * option. * - * There is an exception to this rule. The following methods do not expand - * their argument: cmList::push_back, cmList::emplace and cmList::emplace_back. + * There ate some exceptions to this rule: + * * When the input argument is a cmList instance, the value is not expanded. + * * The following methods do not expand their argument: cmList::push_back, + * cmList::emplace and cmList::emplace_back. */ class cmList @@ -40,7 +45,7 @@ public: using value_type = container_type::value_type; using allocator_type = container_type::allocator_type; - using index_type = int; + using index_type = std::intptr_t; using size_type = container_type::size_type; using difference_type = container_type::difference_type; using reference = container_type::reference; @@ -76,8 +81,18 @@ public: this->assign(value, expandElements, emptyElements); } cmList(cm::string_view value, EmptyElements emptyElements) + : cmList(value, ExpandElements::Yes, emptyElements) + { + } + cmList(std::string const& value, + ExpandElements expandElements = ExpandElements::Yes, + EmptyElements emptyElements = EmptyElements::No) + { + this->assign(value, expandElements, emptyElements); + } + cmList(std::string const& value, EmptyElements emptyElements) + : cmList(value, ExpandElements::Yes, emptyElements) { - this->assign(value, ExpandElements::Yes, emptyElements); } cmList(cmValue list, ExpandElements expandElements = ExpandElements::Yes, EmptyElements emptyElements = EmptyElements::No) @@ -137,6 +152,11 @@ public: this->assign(value); return *this; } + cmList& operator=(std::string const& value) + { + this->assign(value); + return *this; + } cmList& operator=(cmValue value) { if (value) { @@ -177,6 +197,17 @@ public: { this->assign(value, ExpandElements::Yes, emptyElements); } + void assign(std::string const& value, + ExpandElements expandElements = ExpandElements::Yes, + EmptyElements emptyElements = EmptyElements::No) + { + this->clear(); + this->append(value, expandElements, emptyElements); + } + void assign(std::string const& value, EmptyElements emptyElements) + { + this->assign(value, ExpandElements::Yes, emptyElements); + } void assign(cmValue value, ExpandElements expandElements = ExpandElements::Yes, EmptyElements emptyElements = EmptyElements::No) @@ -206,17 +237,17 @@ public: this->assign(first, last, ExpandElements::Yes, emptyElements); } void assign(const cmList& init, - ExpandElements expandElements = ExpandElements::Yes, + ExpandElements expandElements = ExpandElements::No, EmptyElements emptyElements = EmptyElements::No) { this->assign(init.begin(), init.end(), expandElements, emptyElements); } void assign(const cmList& init, EmptyElements emptyElements) { - this->assign(init, ExpandElements::Yes, emptyElements); + this->assign(init, ExpandElements::No, emptyElements); } void assign(cmList&& init, - ExpandElements expandElements = ExpandElements::Yes, + ExpandElements expandElements = ExpandElements::No, EmptyElements emptyElements = EmptyElements::No) { this->assign(std::make_move_iterator(init.begin()), @@ -226,7 +257,7 @@ public: } void assign(cmList&& init, EmptyElements emptyElements) { - this->assign(std::move(init), ExpandElements::Yes, emptyElements); + this->assign(std::move(init), ExpandElements::No, emptyElements); } void assign(const container_type& init, ExpandElements expandElements = ExpandElements::Yes, @@ -267,24 +298,21 @@ public: operator container_type&&() && noexcept { return std::move(this->Values); } // Element access - reference at(index_type pos) + reference at(size_type pos) { return this->Values.at(pos); } + const_reference at(size_type pos) const { return this->Values.at(pos); } + + reference operator[](size_type pos) { return this->Values[pos]; } + const_reference operator[](size_type pos) const { return this->Values[pos]; } + + reference get_item(index_type pos) { return this->Values.at(this->ComputeIndex(pos)); } - const_reference at(index_type pos) const + const_reference get_item(index_type pos) const { return this->Values.at(this->ComputeIndex(pos)); } - reference operator[](index_type pos) - { - return this->Values[this->ComputeIndex(pos, false)]; - } - const_reference operator[](index_type pos) const - { - return this->Values[this->ComputeIndex(pos, false)]; - } - reference front() { return this->Values.front(); } const_reference front() const { return this->Values.front(); } @@ -363,7 +391,7 @@ public: ExpandElements expandElements = ExpandElements::Yes, EmptyElements emptyElements = EmptyElements::No) { - return cmList::Insert(pos, std::string(value), this->Values, + return cmList::Insert(this->Values, pos, std::string(value), expandElements, emptyElements); } iterator insert(const_iterator pos, cm::string_view value, @@ -371,6 +399,18 @@ public: { return this->insert(pos, value, ExpandElements::Yes, emptyElements); } + iterator insert(const_iterator pos, std::string const& value, + ExpandElements expandElements = ExpandElements::Yes, + EmptyElements emptyElements = EmptyElements::No) + { + return cmList::Insert(this->Values, pos, value, expandElements, + emptyElements); + } + iterator insert(const_iterator pos, std::string const& value, + EmptyElements emptyElements) + { + return this->insert(pos, value, ExpandElements::Yes, emptyElements); + } iterator insert(const_iterator pos, cmValue value, ExpandElements expandElements = ExpandElements::Yes, EmptyElements emptyElements = EmptyElements::No) @@ -392,7 +432,7 @@ public: ExpandElements expandElements = ExpandElements::Yes, EmptyElements emptyElements = EmptyElements::No) { - return cmList::Insert(pos, first, last, this->Values, expandElements, + return cmList::Insert(this->Values, pos, first, last, expandElements, emptyElements); } template <typename InputIterator> @@ -402,7 +442,7 @@ public: return this->insert(pos, first, last, ExpandElements::Yes, emptyElements); } iterator insert(const_iterator pos, const cmList& values, - ExpandElements expandElements = ExpandElements::Yes, + ExpandElements expandElements = ExpandElements::No, EmptyElements emptyElements = EmptyElements::No) { return this->insert(pos, values.begin(), values.end(), expandElements, @@ -411,10 +451,10 @@ public: iterator insert(const_iterator pos, const cmList& values, EmptyElements emptyElements) { - return this->insert(pos, values, ExpandElements::Yes, emptyElements); + return this->insert(pos, values, ExpandElements::No, emptyElements); } iterator insert(const_iterator pos, cmList&& values, - ExpandElements expandElements = ExpandElements::Yes, + ExpandElements expandElements = ExpandElements::No, EmptyElements emptyElements = EmptyElements::No) { auto result = this->insert(pos, std::make_move_iterator(values.begin()), @@ -427,7 +467,7 @@ public: iterator insert(const_iterator pos, cmList&& values, EmptyElements emptyElements) { - return this->insert(pos, std::move(values), ExpandElements::Yes, + return this->insert(pos, std::move(values), ExpandElements::No, emptyElements); } iterator insert(const_iterator pos, const container_type& values, @@ -474,6 +514,16 @@ public: { return this->append(value, ExpandElements::Yes, emptyElements); } + iterator append(std::string const& value, + ExpandElements expandElements = ExpandElements::Yes, + EmptyElements emptyElements = EmptyElements::No) + { + return this->insert(this->cend(), value, expandElements, emptyElements); + } + iterator append(std::string const& value, EmptyElements emptyElements) + { + return this->append(value, ExpandElements::Yes, emptyElements); + } iterator append(cmValue value, ExpandElements expandElements = ExpandElements::Yes, EmptyElements emptyElements = EmptyElements::No) @@ -503,7 +553,7 @@ public: return this->append(first, last, ExpandElements::Yes, emptyElements); } iterator append(const cmList& values, - ExpandElements expandElements = ExpandElements::Yes, + ExpandElements expandElements = ExpandElements::No, EmptyElements emptyElements = EmptyElements::No) { return this->append(values.begin(), values.end(), expandElements, @@ -511,10 +561,10 @@ public: } iterator append(const cmList& values, EmptyElements emptyElements) { - return this->append(values, ExpandElements::Yes, emptyElements); + return this->append(values, ExpandElements::No, emptyElements); } iterator append(cmList&& values, - ExpandElements expandElements = ExpandElements::Yes, + ExpandElements expandElements = ExpandElements::No, EmptyElements emptyElements = EmptyElements::No) { auto result = this->append(std::make_move_iterator(values.begin()), @@ -526,7 +576,7 @@ public: } iterator append(cmList&& values, EmptyElements emptyElements) { - return this->append(std::move(values), ExpandElements::Yes, emptyElements); + return this->append(std::move(values), ExpandElements::No, emptyElements); } iterator append(const container_type& values, ExpandElements expandElements = ExpandElements::Yes, @@ -569,6 +619,16 @@ public: { return this->prepend(value, ExpandElements::Yes, emptyElements); } + iterator prepend(std::string const& value, + ExpandElements expandElements = ExpandElements::Yes, + EmptyElements emptyElements = EmptyElements::No) + { + return this->insert(this->cbegin(), value, expandElements, emptyElements); + } + iterator prepend(std::string const& value, EmptyElements emptyElements) + { + return this->prepend(value, ExpandElements::Yes, emptyElements); + } iterator prepend(cmValue value, ExpandElements expandElements = ExpandElements::Yes, EmptyElements emptyElements = EmptyElements::No) @@ -598,7 +658,7 @@ public: return this->prepend(first, last, ExpandElements::Yes, emptyElements); } iterator prepend(const cmList& values, - ExpandElements expandElements = ExpandElements::Yes, + ExpandElements expandElements = ExpandElements::No, EmptyElements emptyElements = EmptyElements::No) { return this->prepend(values.begin(), values.end(), expandElements, @@ -606,10 +666,10 @@ public: } iterator prepend(const cmList& values, EmptyElements emptyElements) { - return this->prepend(values, ExpandElements::Yes, emptyElements); + return this->prepend(values, ExpandElements::No, emptyElements); } iterator prepend(cmList&& values, - ExpandElements expandElements = ExpandElements::Yes, + ExpandElements expandElements = ExpandElements::No, EmptyElements emptyElements = EmptyElements::No) { auto result = this->prepend(std::make_move_iterator(values.begin()), @@ -621,8 +681,7 @@ public: } iterator prepend(cmList&& values, EmptyElements emptyElements) { - return this->prepend(std::move(values), ExpandElements::Yes, - emptyElements); + return this->prepend(std::move(values), ExpandElements::No, emptyElements); } iterator prepend(const container_type& values, ExpandElements expandElements = ExpandElements::Yes, @@ -656,6 +715,7 @@ public: return this->insert(this->cbegin(), ilist); } + void push_back(std::string const& value) { this->Values.push_back(value); } void push_back(cm::string_view value) { this->Values.push_back(std::string{ value }); @@ -735,6 +795,8 @@ public: cmList& remove_duplicates(); + void resize(size_type count) { this->Values.resize(count); } + enum class FilterMode { INCLUDE, @@ -882,46 +944,61 @@ public: // ============== // these methods can be used to store CMake list expansion directly in a // std::vector. - static void assign(cm::string_view value, - std::vector<std::string>& container, + static void assign(std::vector<std::string>& container, + cm::string_view value, EmptyElements emptyElements = EmptyElements::No) { container.clear(); - cmList::append(value, container, emptyElements); + cmList::append(container, value, emptyElements); } - static void assign(cmValue value, std::vector<std::string>& container, + static void assign(std::vector<std::string>& container, + std::string const& value, + EmptyElements emptyElements = EmptyElements::No) + { + container.clear(); + cmList::append(container, value, emptyElements); + } + static void assign(std::vector<std::string>& container, cmValue value, EmptyElements emptyElements = EmptyElements::No) { if (value) { - cmList::assign(*value, container, emptyElements); + cmList::assign(container, *value, emptyElements); } else { container.clear(); } } template <typename InputIterator> - static void assign(InputIterator first, InputIterator last, - std::vector<std::string>& container, + static void assign(std::vector<std::string>& container, InputIterator first, + InputIterator last, EmptyElements emptyElements = EmptyElements::No) { container.clear(); - cmList::append(first, last, container, emptyElements); + cmList::append(container, first, last, emptyElements); } static std::vector<std::string>::iterator insert( - std::vector<std::string>::const_iterator pos, cm::string_view value, std::vector<std::string>& container, + std::vector<std::string>::const_iterator pos, cm::string_view value, EmptyElements emptyElements = EmptyElements::No) { - return cmList::Insert(pos, std::string(value), container, + return cmList::Insert(container, pos, std::string(value), ExpandElements::Yes, emptyElements); } static std::vector<std::string>::iterator insert( - std::vector<std::string>::const_iterator pos, cmValue value, std::vector<std::string>& container, + std::vector<std::string>::const_iterator pos, std::string const& value, + EmptyElements emptyElements = EmptyElements::No) + { + return cmList::Insert(container, pos, value, ExpandElements::Yes, + emptyElements); + } + static std::vector<std::string>::iterator insert( + std::vector<std::string>& container, + std::vector<std::string>::const_iterator pos, cmValue value, EmptyElements emptyElements = EmptyElements::No) { if (value) { - return cmList::insert(pos, *value, container, emptyElements); + return cmList::insert(container, pos, *value, emptyElements); } auto delta = std::distance(container.cbegin(), pos); @@ -929,63 +1006,73 @@ public: } template <typename InputIterator> static std::vector<std::string>::iterator insert( + std::vector<std::string>& container, std::vector<std::string>::const_iterator pos, InputIterator first, - InputIterator last, std::vector<std::string>& container, - EmptyElements emptyElements = EmptyElements::No) + InputIterator last, EmptyElements emptyElements = EmptyElements::No) { - return cmList::Insert(pos, first, last, container, ExpandElements::Yes, + return cmList::Insert(container, pos, first, last, ExpandElements::Yes, emptyElements); } static std::vector<std::string>::iterator append( - cm::string_view value, std::vector<std::string>& container, + std::vector<std::string>& container, cm::string_view value, EmptyElements emptyElements = EmptyElements::No) { - return cmList::insert(container.cend(), value, container, emptyElements); + return cmList::insert(container, container.cend(), value, emptyElements); } static std::vector<std::string>::iterator append( - cmValue value, std::vector<std::string>& container, + std::vector<std::string>& container, std::string const& value, + EmptyElements emptyElements = EmptyElements::No) + { + return cmList::insert(container, container.cend(), value, emptyElements); + } + static std::vector<std::string>::iterator append( + std::vector<std::string>& container, cmValue value, EmptyElements emptyElements = EmptyElements::No) { if (value) { - return cmList::append(*value, container, emptyElements); + return cmList::append(container, *value, emptyElements); } return container.end(); } template <typename InputIterator> static std::vector<std::string>::iterator append( - InputIterator first, InputIterator last, - std::vector<std::string>& container, - EmptyElements emptyElements = EmptyElements::No) + std::vector<std::string>& container, InputIterator first, + InputIterator last, EmptyElements emptyElements = EmptyElements::No) { - return cmList::insert(container.cend(), first, last, container, + return cmList::insert(container, container.cend(), first, last, emptyElements); } static std::vector<std::string>::iterator prepend( - cm::string_view value, std::vector<std::string>& container, + std::vector<std::string>& container, cm::string_view value, EmptyElements emptyElements = EmptyElements::No) { - return cmList::insert(container.cbegin(), value, container, emptyElements); + return cmList::insert(container, container.cbegin(), value, emptyElements); } static std::vector<std::string>::iterator prepend( - cmValue value, std::vector<std::string>& container, + std::vector<std::string>& container, std::string const& value, + EmptyElements emptyElements = EmptyElements::No) + { + return cmList::insert(container, container.cbegin(), value, emptyElements); + } + static std::vector<std::string>::iterator prepend( + std::vector<std::string>& container, cmValue value, EmptyElements emptyElements = EmptyElements::No) { if (value) { - return cmList::prepend(*value, container, emptyElements); + return cmList::prepend(container, *value, emptyElements); } return container.begin(); } template <typename InputIterator> static std::vector<std::string>::iterator prepend( - InputIterator first, InputIterator last, - std::vector<std::string>& container, - EmptyElements emptyElements = EmptyElements::No) + std::vector<std::string>& container, InputIterator first, + InputIterator last, EmptyElements emptyElements = EmptyElements::No) { - return cmList::insert(container.cbegin(), first, last, container, + return cmList::insert(container, container.cbegin(), first, last, emptyElements); } @@ -993,40 +1080,40 @@ public: // but without any intermediate expansion. So the operation is simply a // string concatenation with special handling for the CMake list item // separator - static std::string& append(cm::string_view value, std::string& list); + static std::string& append(std::string& list, cm::string_view value); template <typename InputIterator> - static std::string& append(InputIterator first, InputIterator last, - std::string& list) + static std::string& append(std::string& list, InputIterator first, + InputIterator last) { if (first == last) { return list; } - return cmList::append(cm::string_view{ std::accumulate( + return cmList::append(list, + cm::string_view{ std::accumulate( std::next(first), last, *first, [](std::string a, const std::string& b) { return std::move(a) + std::string(cmList::element_separator) + b; - }) }, - list); + }) }); } - static std::string& prepend(cm::string_view value, std::string& list); + static std::string& prepend(std::string& list, cm::string_view value); template <typename InputIterator> - static std::string& prepend(InputIterator first, InputIterator last, - std::string& list) + static std::string& prepend(std::string& list, InputIterator first, + InputIterator last) { if (first == last) { return list; } - return cmList::prepend(cm::string_view{ std::accumulate( + return cmList::prepend(list, + cm::string_view{ std::accumulate( std::next(first), last, *first, [](std::string a, const std::string& b) { return std::move(a) + std::string(cmList::element_separator) + b; - }) }, - list); + }) }); } // Non-members @@ -1049,26 +1136,26 @@ private: cmList& RemoveItems(std::vector<index_type>&& indexes); cmList& RemoveItems(std::vector<std::string>&& items); - static container_type::iterator Insert(container_type::const_iterator pos, + static container_type::iterator Insert(container_type& container, + container_type::const_iterator pos, std::string&& value, - container_type& container, ExpandElements expandElements, EmptyElements emptyElements); - static container_type::iterator Insert(container_type::const_iterator pos, + static container_type::iterator Insert(container_type& container, + container_type::const_iterator pos, const std::string& value, - container_type& container, ExpandElements expandElements, EmptyElements emptyElements) { auto tmp = value; - return cmList::Insert(pos, std::move(tmp), container, expandElements, + return cmList::Insert(container, pos, std::move(tmp), expandElements, emptyElements); } template <typename InputIterator> - static container_type::iterator Insert(container_type::const_iterator pos, + static container_type::iterator Insert(container_type& container, + container_type::const_iterator pos, InputIterator first, InputIterator last, - container_type& container, ExpandElements expandElements, EmptyElements emptyElements) { @@ -1082,7 +1169,7 @@ private: if (expandElements == ExpandElements::Yes) { for (; first != last; ++first) { auto size = container.size(); - insertPos = cmList::Insert(insertPos, *first, container, + insertPos = cmList::Insert(container, insertPos, *first, expandElements, emptyElements); insertPos += container.size() - size; } @@ -1246,3 +1333,20 @@ void append(cmList& v, Range const& r) #endif } // namespace cm + +/** + * Helper functions for legacy support. Use preferably cmList class directly + * or the static methods of the class. + */ +inline void cmExpandList( + cm::string_view arg, std::vector<std::string>& argsOut, + cmList::EmptyElements emptyElements = cmList::EmptyElements::No) +{ + cmList::append(argsOut, arg, emptyElements); +} +inline void cmExpandList( + cmValue arg, std::vector<std::string>& argsOut, + cmList::EmptyElements emptyElements = cmList::EmptyElements::No) +{ + cmList::append(argsOut, arg, emptyElements); +} diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index 40be0ce..acffa2e 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -205,7 +205,7 @@ bool HandleAppendCommand(std::vector<std::string> const& args, GetListString(listString, listName, makefile); makefile.AddDefinition( - listName, cmList::append(args.begin() + 2, args.end(), listString)); + listName, cmList::append(listString, args.begin() + 2, args.end())); return true; } @@ -226,7 +226,7 @@ bool HandlePrependCommand(std::vector<std::string> const& args, GetListString(listString, listName, makefile); makefile.AddDefinition( - listName, cmList::prepend(args.begin() + 2, args.end(), listString)); + listName, cmList::prepend(listString, args.begin() + 2, args.end())); return true; } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index e00341c..64f0246 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -147,12 +147,10 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, cmMakefile* makefile) this->Makefile->GetDefinition("CMAKE_APPLE_ARCH_SYSROOTS")) { std::string const& appleArchs = this->Makefile->GetSafeDefinition("CMAKE_OSX_ARCHITECTURES"); - std::vector<std::string> archs; - std::vector<std::string> sysroots; - cmExpandList(appleArchs, archs); - cmExpandList(*appleArchSysroots, sysroots, true); + cmList archs(appleArchs); + cmList sysroots{ appleArchSysroots, cmList::EmptyElements::Yes }; if (archs.size() == sysroots.size()) { - for (size_t i = 0; i < archs.size(); ++i) { + for (cmList::size_type i = 0; i < archs.size(); ++i) { this->AppleArchSysroots[archs[i]] = sysroots[i]; } } else { @@ -1169,11 +1167,11 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit( // Standard include directories to be added unconditionally at the end. // These are intended to simulate additional implicit include directories. - std::vector<std::string> userStandardDirs; + cmList userStandardDirs; { std::string const value = this->Makefile->GetSafeDefinition( cmStrCat("CMAKE_", lang, "_STANDARD_INCLUDE_DIRECTORIES")); - cmExpandList(value, userStandardDirs); + userStandardDirs.assign(value); for (std::string& usd : userStandardDirs) { cmSystemTools::ConvertToUnixSlashes(usd); } @@ -1196,13 +1194,12 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit( // directories for modules ('.mod' files). if (lang != "Fortran") { size_t const impDirVecOldSize = impDirVec.size(); - if (this->Makefile->GetDefExpandList( - cmStrCat("CMAKE_", lang, "_IMPLICIT_INCLUDE_DIRECTORIES"), - impDirVec)) { - // FIXME: Use cmRange with 'advance()' when it supports non-const. - for (size_t i = impDirVecOldSize; i < impDirVec.size(); ++i) { - cmSystemTools::ConvertToUnixSlashes(impDirVec[i]); - } + cmList::append(impDirVec, + this->Makefile->GetDefinition(cmStrCat( + "CMAKE_", lang, "_IMPLICIT_INCLUDE_DIRECTORIES"))); + // FIXME: Use cmRange with 'advance()' when it supports non-const. + for (size_t i = impDirVecOldSize; i < impDirVec.size(); ++i) { + cmSystemTools::ConvertToUnixSlashes(impDirVec[i]); } } @@ -2448,10 +2445,9 @@ void cmLocalGenerator::AddColorDiagnosticsFlags(std::string& flags, cmStrCat("CMAKE_", lang, "_COMPILE_OPTIONS_COLOR_DIAGNOSTICS_OFF"); } - std::vector<std::string> options; - this->Makefile->GetDefExpandList(colorFlagName, options); + cmList options{ this->Makefile->GetDefinition(colorFlagName) }; - for (std::string const& option : options) { + for (auto const& option : options) { this->AppendFlagEscape(flags, option); } } @@ -2974,6 +2970,7 @@ void cmLocalGenerator::WriteUnitySourceInclude( unity_file << *beforeInclude << "\n"; } + unity_file << "// NOLINTNEXTLINE(bugprone-suspicious-include)\n"; unity_file << "#include \"" << sf_full_path << "\"\n"; if (afterInclude) { @@ -4386,12 +4383,11 @@ void AddUtilityCommand(cmLocalGenerator& lg, cmCommandOrigin origin, std::vector<std::string> ComputeISPCObjectSuffixes(cmGeneratorTarget* target) { - const std::string& targetProperty = - target->GetSafeProperty("ISPC_INSTRUCTION_SETS"); - std::vector<std::string> ispcTargets; + const cmValue targetProperty = target->GetProperty("ISPC_INSTRUCTION_SETS"); + cmList ispcTargets; - if (!cmIsOff(targetProperty)) { - cmExpandList(targetProperty, ispcTargets); + if (!targetProperty.IsOff()) { + ispcTargets.assign(targetProperty); for (auto& ispcTarget : ispcTargets) { // transform targets into the suffixes auto pos = ispcTarget.find('-'); @@ -4403,7 +4399,7 @@ std::vector<std::string> ComputeISPCObjectSuffixes(cmGeneratorTarget* target) ispcTarget = target_suffix; } } - return ispcTargets; + return std::move(ispcTargets.data()); } std::vector<std::string> ComputeISPCExtraObjects( diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 42fa298..a047233 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -909,14 +909,11 @@ void cmLocalNinjaGenerator::AdditionalCleanFiles(const std::string& config) { if (cmValue prop_value = this->Makefile->GetProperty("ADDITIONAL_CLEAN_FILES")) { - std::vector<std::string> cleanFiles; - { - cmExpandList(cmGeneratorExpression::Evaluate(*prop_value, this, config), - cleanFiles); - } + cmList cleanFiles{ cmGeneratorExpression::Evaluate(*prop_value, this, + config) }; std::string const& binaryDir = this->GetCurrentBinaryDirectory(); cmGlobalNinjaGenerator* gg = this->GetGlobalNinjaGenerator(); - for (std::string const& cleanFile : cleanFiles) { + for (auto const& cleanFile : cleanFiles) { // Support relative paths gg->AddAdditionalCleanFile( cmSystemTools::CollapseFullPath(cleanFile, binaryDir), config); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 12cecbd..d8f532f 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1130,14 +1130,13 @@ void cmLocalUnixMakefileGenerator3::AppendCleanCommand( void cmLocalUnixMakefileGenerator3::AppendDirectoryCleanCommand( std::vector<std::string>& commands) { - std::vector<std::string> cleanFiles; + cmList cleanFiles; // Look for additional files registered for cleaning in this directory. if (cmValue prop_value = this->Makefile->GetProperty("ADDITIONAL_CLEAN_FILES")) { - cmExpandList(cmGeneratorExpression::Evaluate( - *prop_value, this, - this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")), - cleanFiles); + cleanFiles.assign(cmGeneratorExpression::Evaluate( + *prop_value, this, + this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"))); } if (cleanFiles.empty()) { return; @@ -1973,14 +1972,14 @@ void cmLocalUnixMakefileGenerator3::WriteDependLanguageInfo( // Store include transform rule properties. Write the directory // rules first because they may be overridden by later target rules. - std::vector<std::string> transformRules; + cmList transformRules; if (cmValue xform = this->Makefile->GetProperty("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM")) { - cmExpandList(*xform, transformRules); + transformRules.assign(*xform); } if (cmValue xform = target->GetProperty("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM")) { - cmExpandList(*xform, transformRules); + transformRules.append(*xform); } if (!transformRules.empty()) { cmakefileStream << "\nset(CMAKE_INCLUDE_TRANSFORMS\n"; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 490a905..01afc44 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1957,21 +1957,15 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value, value = existingValue->c_str(); } if (type == cmStateEnums::PATH || type == cmStateEnums::FILEPATH) { - std::vector<std::string>::size_type cc; - std::vector<std::string> files; nvalue = value ? value : ""; - cmExpandList(nvalue, files); - nvalue.clear(); - for (cc = 0; cc < files.size(); cc++) { - if (!cmIsOff(files[cc])) { - files[cc] = cmSystemTools::CollapseFullPath(files[cc]); + cmList files(nvalue); + for (auto& file : files) { + if (!cmIsOff(file)) { + file = cmSystemTools::CollapseFullPath(file); } - if (cc > 0) { - nvalue += ";"; - } - nvalue += files[cc]; } + nvalue = files.to_string(); this->GetCMakeInstance()->AddCacheEntry(name, nvalue, doc, type); nvalue = *this->GetState()->GetInitializedCacheValue(name); @@ -2613,18 +2607,6 @@ const std::string& cmMakefile::GetSafeDefinition(const std::string& name) const return this->GetDefinition(name); } -bool cmMakefile::GetDefExpandList(const std::string& name, - std::vector<std::string>& out, - bool emptyArgs) const -{ - cmValue def = this->GetDefinition(name); - if (!def) { - return false; - } - cmExpandList(*def, out, emptyArgs); - return true; -} - std::vector<std::string> cmMakefile::GetDefinitions() const { std::vector<std::string> res = this->StateSnapshot.ClosureKeys(); @@ -3265,9 +3247,9 @@ std::string cmMakefile::GetDefaultConfiguration() const std::vector<std::string> cmMakefile::GetGeneratorConfigs( GeneratorConfigQuery mode) const { - std::vector<std::string> configs; + cmList configs; if (this->GetGlobalGenerator()->IsMultiConfig()) { - this->GetDefExpandList("CMAKE_CONFIGURATION_TYPES", configs); + configs.assign(this->GetDefinition("CMAKE_CONFIGURATION_TYPES")); } else if (mode != cmMakefile::OnlyMultiConfig) { const std::string& buildType = this->GetSafeDefinition("CMAKE_BUILD_TYPE"); if (!buildType.empty()) { @@ -3277,7 +3259,7 @@ std::vector<std::string> cmMakefile::GetGeneratorConfigs( if (mode == cmMakefile::IncludeEmptyConfig && configs.empty()) { configs.emplace_back(); } - return configs; + return std::move(configs.data()); } bool cmMakefile::IsFunctionBlocked(const cmListFileFunction& lff, @@ -4154,11 +4136,11 @@ void cmMakefile::GetTests(const std::string& config, void cmMakefile::AddCMakeDependFilesFromUser() { - std::vector<std::string> deps; + cmList deps; if (cmValue deps_str = this->GetProperty("CMAKE_CONFIGURE_DEPENDS")) { - cmExpandList(*deps_str, deps); + deps.assign(*deps_str); } - for (std::string const& dep : deps) { + for (auto const& dep : deps) { if (cmSystemTools::FileIsFullPath(dep)) { this->AddCMakeDependFile(dep); } else { diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index a43ff41..d1f5be5 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -518,8 +518,6 @@ public: const std::string& GetRequiredDefinition(const std::string& name) const; bool IsDefinitionSet(const std::string&) const; bool IsNormalDefinitionSet(const std::string&) const; - bool GetDefExpandList(const std::string& name, std::vector<std::string>& out, - bool emptyArgs = false) const; /** * Get the list of all variables in the current space. If argument * cacheonly is specified and is greater than 0, then only cache diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 1960073..3caabde 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -16,6 +16,7 @@ #include "cmGlobalUnixMakefileGenerator3.h" #include "cmLinkLineComputer.h" #include "cmLinkLineDeviceComputer.h" +#include "cmList.h" #include "cmLocalGenerator.h" #include "cmLocalUnixMakefileGenerator3.h" #include "cmMakefile.h" @@ -151,11 +152,10 @@ void cmMakefileExecutableTargetGenerator::WriteNvidiaDeviceExecutableRule( bool useLinkScript = this->GlobalGenerator->GetUseLinkScript(); // Construct the main link rule. - std::vector<std::string> real_link_commands; const std::string linkRuleVar = "CMAKE_CUDA_DEVICE_LINK_EXECUTABLE"; const std::string linkRule = this->GetLinkRule(linkRuleVar); std::vector<std::string> commands1; - cmExpandList(linkRule, real_link_commands); + cmList real_link_commands(linkRule); bool useResponseFileForObjects = this->CheckUseResponseFileForObjects(linkLanguage); @@ -235,7 +235,7 @@ void cmMakefileExecutableTargetGenerator::WriteNvidiaDeviceExecutableRule( // Expand placeholders in the commands. rulePlaceholderExpander->SetTargetImpLib(targetOutput); - for (std::string& real_link_command : real_link_commands) { + for (auto& real_link_command : real_link_commands) { real_link_command = cmStrCat(launcher, real_link_command); rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator, real_link_command, vars); @@ -466,18 +466,18 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) bool useLinkScript = this->GlobalGenerator->GetUseLinkScript(); // Construct the main link rule. - std::vector<std::string> real_link_commands; std::string linkRuleVar = this->GeneratorTarget->GetCreateRuleVariable( linkLanguage, this->GetConfigName()); std::string linkRule = this->GetLinkRule(linkRuleVar); std::vector<std::string> commands1; - cmExpandList(linkRule, real_link_commands); + cmList real_link_commands(linkRule); + if (this->GeneratorTarget->IsExecutableWithExports()) { // If a separate rule for creating an import library is specified // add it now. std::string implibRuleVar = cmStrCat("CMAKE_", linkLanguage, "_CREATE_IMPORT_LIBRARY"); - this->Makefile->GetDefExpandList(implibRuleVar, real_link_commands); + real_link_commands.append(this->Makefile->GetDefinition(implibRuleVar)); } bool useResponseFileForObjects = @@ -601,7 +601,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // Expand placeholders in the commands. rulePlaceholderExpander->SetTargetImpLib(targetOutPathImport); - for (std::string& real_link_command : real_link_commands) { + for (auto& real_link_command : real_link_commands) { real_link_command = cmStrCat(launcher, real_link_command); rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator, real_link_command, vars); diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 43062d9..691edf4 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -305,7 +305,7 @@ void cmMakefileLibraryTargetGenerator::WriteNvidiaDeviceLibraryRules( vars.Language = linkLanguage.c_str(); // Expand the rule variables. - std::vector<std::string> real_link_commands; + cmList real_link_commands; { // Set path conversion for link script shells. this->LocalGenerator->SetLinkScriptShell(useLinkScript); @@ -376,10 +376,10 @@ void cmMakefileLibraryTargetGenerator::WriteNvidiaDeviceLibraryRules( // Construct the main link rule and expand placeholders. rulePlaceholderExpander->SetTargetImpLib(targetOutput); std::string linkRule = this->GetLinkRule(linkRuleVar); - cmExpandList(linkRule, real_link_commands); + real_link_commands.append(linkRule); // Expand placeholders. - for (std::string& real_link_command : real_link_commands) { + for (auto& real_link_command : real_link_commands) { real_link_command = cmStrCat(launcher, real_link_command); rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator, real_link_command, vars); @@ -641,9 +641,9 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( // For static libraries there might be archiving rules. bool haveStaticLibraryRule = false; - std::vector<std::string> archiveCreateCommands; - std::vector<std::string> archiveAppendCommands; - std::vector<std::string> archiveFinishCommands; + cmList archiveCreateCommands; + cmList archiveAppendCommands; + cmList archiveFinishCommands; std::string::size_type archiveCommandLimit = std::string::npos; if (this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY) { haveStaticLibraryRule = this->Makefile->IsDefinitionSet(linkRuleVar); @@ -653,21 +653,23 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( arCreateVar = this->GeneratorTarget->GetFeatureSpecificLinkRuleVariable( arCreateVar, linkLanguage, this->GetConfigName()); - this->Makefile->GetDefExpandList(arCreateVar, archiveCreateCommands); + archiveCreateCommands.assign(this->Makefile->GetDefinition(arCreateVar)); + std::string arAppendVar = cmStrCat("CMAKE_", linkLanguage, "_ARCHIVE_APPEND"); arAppendVar = this->GeneratorTarget->GetFeatureSpecificLinkRuleVariable( arAppendVar, linkLanguage, this->GetConfigName()); - this->Makefile->GetDefExpandList(arAppendVar, archiveAppendCommands); + archiveAppendCommands.assign(this->Makefile->GetDefinition(arAppendVar)); + std::string arFinishVar = cmStrCat("CMAKE_", linkLanguage, "_ARCHIVE_FINISH"); arFinishVar = this->GeneratorTarget->GetFeatureSpecificLinkRuleVariable( arFinishVar, linkLanguage, this->GetConfigName()); - this->Makefile->GetDefExpandList(arFinishVar, archiveFinishCommands); + archiveFinishCommands.assign(this->Makefile->GetDefinition(arFinishVar)); } // Decide whether to use archiving rules. @@ -695,7 +697,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( this->LocalGenerator->CreateRulePlaceholderExpander()); bool useWatcomQuote = this->Makefile->IsOn(linkRuleVar + "_USE_WATCOM_QUOTE"); - std::vector<std::string> real_link_commands; + cmList real_link_commands; { // Set path conversion for link script shells. this->LocalGenerator->SetLinkScriptShell(useLinkScript); @@ -880,7 +882,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( } else { // Get the set of commands. std::string linkRule = this->GetLinkRule(linkRuleVar); - cmExpandList(linkRule, real_link_commands); + real_link_commands.append(linkRule); if (this->UseLWYU) { cmValue lwyuCheck = this->Makefile->GetDefinition("CMAKE_LINK_WHAT_YOU_USE_CHECK"); @@ -896,7 +898,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( } // Expand placeholders. - for (std::string& real_link_command : real_link_commands) { + for (auto& real_link_command : real_link_commands) { real_link_command = cmStrCat(launcher, real_link_command); rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator, real_link_command, vars); diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 1e35fe7..a0a7324 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -208,27 +208,24 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() // -- Write the custom commands for this target // Evaluates generator expressions and expands prop_value - auto evaluatedFiles = - [this](const std::string& prop_value) -> std::vector<std::string> { - std::vector<std::string> files; - cmExpandList(cmGeneratorExpression::Evaluate( - prop_value, this->LocalGenerator, this->GetConfigName(), - this->GeneratorTarget), - files); + auto evaluatedFiles = [this](const std::string& prop_value) -> cmList { + cmList files{ cmGeneratorExpression::Evaluate( + prop_value, this->LocalGenerator, this->GetConfigName(), + this->GeneratorTarget) }; return files; }; // Look for additional files registered for cleaning in this directory. if (cmValue prop_value = this->Makefile->GetProperty("ADDITIONAL_MAKE_CLEAN_FILES")) { - std::vector<std::string> const files = evaluatedFiles(*prop_value); + auto const files = evaluatedFiles(*prop_value); this->CleanFiles.insert(files.begin(), files.end()); } // Look for additional files registered for cleaning in this target. if (cmValue prop_value = this->GeneratorTarget->GetProperty("ADDITIONAL_CLEAN_FILES")) { - std::vector<std::string> const files = evaluatedFiles(*prop_value); + auto const files = evaluatedFiles(*prop_value); // For relative path support std::string const& binaryDir = this->LocalGenerator->GetCurrentBinaryDirectory(); @@ -1003,10 +1000,10 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( vars.CudaCompileMode = cudaCompileMode.c_str(); } - std::vector<std::string> compileCommands; + cmList compileCommands; const std::string& compileRule = this->Makefile->GetRequiredDefinition( "CMAKE_" + lang + "_COMPILE_OBJECT"); - cmExpandList(compileRule, compileCommands); + compileCommands.assign(compileRule); if (this->GeneratorTarget->GetPropertyAsBool("EXPORT_COMPILE_COMMANDS") && lang_can_export_cmds && compileCommands.size() == 1) { @@ -1209,7 +1206,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( i = this->LocalGenerator->EscapeForShell(i); } } - compileCommands.front().insert(0, cmJoin(args, " ") + " "); + compileCommands.front().insert(0, args.join(" ") + " "); } std::string launcher; @@ -1241,9 +1238,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( const auto& extraCommands = this->Makefile->GetSafeDefinition( cmStrCat("CMAKE_", lang, "_DEPENDS_EXTRA_COMMANDS")); if (!extraCommands.empty()) { - cmList commandList{ extraCommands }; - compileCommands.insert(compileCommands.end(), commandList.cbegin(), - commandList.cend()); + compileCommands.append(extraCommands); } const auto& depFormat = this->Makefile->GetRequiredDefinition( @@ -1284,14 +1279,15 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( } // Check for extra outputs created by the compilation. - std::vector<std::string> outputs(1, relativeObj); + cmList outputs; + outputs.emplace_back(relativeObj); if (cmValue extra_outputs_str = source.GetProperty("OBJECT_OUTPUTS")) { std::string evaluated_outputs = cmGeneratorExpression::Evaluate( *extra_outputs_str, this->LocalGenerator, config); if (!evaluated_outputs.empty()) { // Register these as extra files to clean. - cmExpandList(evaluated_outputs, outputs); + outputs.append(evaluated_outputs); } } if (!ispcHeaderRelative.empty()) { diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 091acd6..ee4fa90 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -610,7 +610,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile, std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeDeviceLinkCmd() { - std::vector<std::string> linkCmds; + cmList linkCmds; // this target requires separable cuda compilation // now build the correct command depending on if the target is @@ -619,23 +619,23 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeDeviceLinkCmd() case cmStateEnums::STATIC_LIBRARY: case cmStateEnums::SHARED_LIBRARY: case cmStateEnums::MODULE_LIBRARY: { - this->GetMakefile()->GetDefExpandList("CMAKE_CUDA_DEVICE_LINK_LIBRARY", - linkCmds); + linkCmds.assign( + this->GetMakefile()->GetDefinition("CMAKE_CUDA_DEVICE_LINK_LIBRARY")); } break; case cmStateEnums::EXECUTABLE: { - this->GetMakefile()->GetDefExpandList( - "CMAKE_CUDA_DEVICE_LINK_EXECUTABLE", linkCmds); + linkCmds.assign(this->GetMakefile()->GetDefinition( + "CMAKE_CUDA_DEVICE_LINK_EXECUTABLE")); } break; default: break; } - return linkCmds; + return std::move(linkCmds.data()); } std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd( const std::string& config) { - std::vector<std::string> linkCmds; + cmList linkCmds; cmMakefile* mf = this->GetMakefile(); { // If we have a rule variable prefer it. In the case of static libraries @@ -654,7 +654,7 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd( linkCmdStr += *rule; } } - cmExpandList(linkCmdStr, linkCmds); + linkCmds.assign(linkCmdStr); if (this->UseLWYU) { cmValue lwyuCheck = mf->GetDefinition("CMAKE_LINK_WHAT_YOU_USE_CHECK"); if (lwyuCheck) { @@ -673,7 +673,7 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd( linkCmds.push_back(std::move(cmakeCommand)); } } - return linkCmds; + return std::move(linkCmds.data()); } } switch (this->GetGeneratorTarget()->GetType()) { @@ -694,7 +694,7 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd( linkCmdVar, this->TargetLinkLanguage(config), config); std::string const& linkCmd = mf->GetRequiredDefinition(linkCmdVar); - cmExpandList(linkCmd, linkCmds); + linkCmds.append(linkCmd); } { std::string linkCmdVar = cmStrCat( @@ -704,7 +704,7 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd( linkCmdVar, this->TargetLinkLanguage(config), config); std::string const& linkCmd = mf->GetRequiredDefinition(linkCmdVar); - cmExpandList(linkCmd, linkCmds); + linkCmds.append(linkCmd); } #ifdef __APPLE__ // On macOS ranlib truncates the fractional part of the static archive @@ -728,7 +728,7 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd( default: assert(false && "Unexpected target type"); } - return linkCmds; + return std::move(linkCmds.data()); } void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement( diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 905c68e..7ce6c96 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -9,6 +9,7 @@ #include <iterator> #include <map> #include <ostream> +#include <type_traits> #include <unordered_map> #include <unordered_set> #include <utility> @@ -21,8 +22,6 @@ #include <cm3p/json/value.h> #include <cm3p/json/writer.h> -#include "cmsys/RegularExpression.hxx" - #include "cmComputeLinkInformation.h" #include "cmCustomCommandGenerator.h" #include "cmDyndepCollation.h" @@ -690,7 +689,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang, // Rule to scan dependencies of sources that need preprocessing. { - std::vector<std::string> scanCommands; + cmList scanCommands; std::string scanRuleName; std::string ppFileName; if (compilationPreprocesses) { @@ -698,8 +697,8 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang, ppFileName = "$PREPROCESSED_OUTPUT_FILE"; std::string const& scanCommand = mf->GetRequiredDefinition( cmStrCat("CMAKE_EXPERIMENTAL_", lang, "_SCANDEP_SOURCE")); - cmExpandList(scanCommand, scanCommands); - for (std::string& i : scanCommands) { + scanCommands.assign(scanCommand); + for (auto& i : scanCommands) { i = cmStrCat(launcher, i); } } else { @@ -707,8 +706,8 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang, ppFileName = "$out"; std::string const& ppCommmand = mf->GetRequiredDefinition( cmStrCat("CMAKE_", lang, "_PREPROCESS_SOURCE")); - cmExpandList(ppCommmand, scanCommands); - for (std::string& i : scanCommands) { + scanCommands.assign(ppCommmand); + for (auto& i : scanCommands) { i = cmStrCat(launcher, i); } scanCommands.emplace_back(GetScanCommand(cmakeCmd, tdi, lang, "$out", @@ -887,10 +886,9 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang, } // Rule for compiling object file. - std::vector<std::string> compileCmds; const std::string cmdVar = cmStrCat("CMAKE_", lang, "_COMPILE_OBJECT"); const std::string& compileCmd = mf->GetRequiredDefinition(cmdVar); - cmExpandList(compileCmd, compileCmds); + cmList compileCmds(compileCmd); // See if we need to use a compiler launcher like ccache or distcc std::string compilerLauncher; @@ -1057,12 +1055,10 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang, const auto& extraCommands = this->GetMakefile()->GetSafeDefinition( cmStrCat("CMAKE_", lang, "_DEPENDS_EXTRA_COMMANDS")); if (!extraCommands.empty()) { - cmList commandList{ extraCommands }; - compileCmds.insert(compileCmds.end(), commandList.cbegin(), - commandList.cend()); + compileCmds.append(extraCommands); } - for (std::string& i : compileCmds) { + for (auto& i : compileCmds) { i = cmStrCat(launcher, i); rulePlaceholderExpander->ExpandRuleVariables(this->GetLocalGenerator(), i, vars); @@ -1262,7 +1258,6 @@ namespace { cmNinjaBuild GetScanBuildStatement(const std::string& ruleName, const std::string& ppFileName, bool compilePP, bool compilePPWithDefines, - cmValue ppExcludeFlagsRegex, cmNinjaBuild& objBuild, cmNinjaVars& vars, const std::string& objectFileName, cmLocalGenerator* lg) @@ -1291,20 +1286,6 @@ cmNinjaBuild GetScanBuildStatement(const std::string& ruleName, // Scanning and compilation generally use the same flags. scanBuild.Variables["FLAGS"] = vars["FLAGS"]; - // Exclude flags not valid during preprocessing. - if (compilePP && !ppExcludeFlagsRegex.IsEmpty()) { - std::string in = std::move(scanBuild.Variables["FLAGS"]); - std::string out; - cmsys::RegularExpression regex(*ppExcludeFlagsRegex); - std::string::size_type pos = 0; - while (regex.find(in.c_str() + pos)) { - out = cmStrCat(out, in.substr(pos, regex.start()), ' '); - pos += regex.end(); - } - out = cmStrCat(out, in.substr(pos)); - scanBuild.Variables["FLAGS"] = std::move(out); - } - if (compilePP && !compilePPWithDefines) { // Move preprocessor definitions to the scan/preprocessor build statement. std::swap(scanBuild.Variables["DEFINES"], vars["DEFINES"]); @@ -1529,22 +1510,18 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( std::string scanRuleName; std::string ppFileName; - cmValue ppExcludeFlagsRegex; if (compilePP) { scanRuleName = this->LanguagePreprocessAndScanRule(language, config); ppFileName = this->ConvertToNinjaPath( this->GetPreprocessedFilePath(source, config)); - ppExcludeFlagsRegex = this->Makefile->GetDefinition(cmStrCat( - "CMAKE_", language, "_PREPROCESS_SOURCE_EXCLUDE_FLAGS_REGEX")); } else { scanRuleName = this->LanguageScanRule(language, config); ppFileName = cmStrCat(objectFileName, ".ddi.i"); } cmNinjaBuild ppBuild = GetScanBuildStatement( - scanRuleName, ppFileName, compilePP, compilePPWithDefines, - ppExcludeFlagsRegex, objBuild, vars, objectFileName, - this->LocalGenerator); + scanRuleName, ppFileName, compilePP, compilePPWithDefines, objBuild, + vars, objectFileName, this->LocalGenerator); if (compilePP) { // In case compilation requires flags that are incompatible with @@ -1883,16 +1860,15 @@ void cmNinjaTargetGenerator::ExportObjectCompileCommand( compileObjectVars.CudaCompileMode = cudaCompileMode.c_str(); } - std::vector<std::string> compileCmds; const std::string cmdVar = cmStrCat("CMAKE_", language, "_COMPILE_OBJECT"); const std::string& compileCmd = this->Makefile->GetRequiredDefinition(cmdVar); - cmExpandList(compileCmd, compileCmds); + cmList compileCmds(compileCmd); std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander( this->GetLocalGenerator()->CreateRulePlaceholderExpander()); - for (std::string& i : compileCmds) { + for (auto& i : compileCmds) { // no launcher for CMAKE_EXPORT_COMPILE_COMMANDS rulePlaceholderExpander->ExpandRuleVariables(this->GetLocalGenerator(), i, compileObjectVars); @@ -1910,13 +1886,11 @@ void cmNinjaTargetGenerator::AdditionalCleanFiles(const std::string& config) if (cmValue prop_value = this->GeneratorTarget->GetProperty("ADDITIONAL_CLEAN_FILES")) { cmLocalNinjaGenerator* lg = this->LocalGenerator; - std::vector<std::string> cleanFiles; - cmExpandList(cmGeneratorExpression::Evaluate(*prop_value, lg, config, - this->GeneratorTarget), - cleanFiles); + cmList cleanFiles(cmGeneratorExpression::Evaluate(*prop_value, lg, config, + this->GeneratorTarget)); std::string const& binaryDir = lg->GetCurrentBinaryDirectory(); cmGlobalNinjaGenerator* gg = lg->GetGlobalNinjaGenerator(); - for (std::string const& cleanFile : cleanFiles) { + for (auto const& cleanFile : cleanFiles) { // Support relative paths gg->AddAdditionalCleanFile( cmSystemTools::CollapseFullPath(cleanFile, binaryDir), config); diff --git a/Source/cmParseArgumentsCommand.cxx b/Source/cmParseArgumentsCommand.cxx index 3e677e6..b0462f0 100644 --- a/Source/cmParseArgumentsCommand.cxx +++ b/Source/cmParseArgumentsCommand.cxx @@ -174,13 +174,11 @@ bool cmParseArgumentsCommand(std::vector<std::string> const& args, parser.Bind(list, options, duplicateKey); // the third argument is a (cmake) list of single argument options - list.clear(); - cmExpandList(*argIter++, list); + list.assign(*argIter++); parser.Bind(list, singleValArgs, duplicateKey); // the fourth argument is a (cmake) list of multi argument options - list.clear(); - cmExpandList(*argIter++, list); + list.assign(*argIter++); parser.Bind(list, multiValArgs, duplicateKey); list.clear(); @@ -188,7 +186,7 @@ bool cmParseArgumentsCommand(std::vector<std::string> const& args, // Flatten ;-lists in the arguments into a single list as was done // by the original function(CMAKE_PARSE_ARGUMENTS). for (; argIter != argEnd; ++argIter) { - cmExpandList(*argIter, list); + list.append(*argIter); } } else { // in the PARSE_ARGV move read the arguments from ARGC and ARGV# diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 544e1ef..d897f0e 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -559,9 +559,7 @@ bool cmQtAutoGenInitializer::InitCustomTargets() "Q_PLUGIN_METADATA", "[\n][ \t]*Q_PLUGIN_METADATA[ \t]*\\(" "[^\\)]*FILE[ \t]*\"([^\"]+)\""); - for (cmList::index_type ii = 0; - ii != static_cast<cmList::index_type>(filterList.size()); - ii += 2) { + for (cmList::size_type ii = 0; ii != filterList.size(); ii += 2) { this->Moc.DependFilters.emplace_back(filterList[ii], filterList[ii + 1]); } @@ -640,8 +638,9 @@ bool cmQtAutoGenInitializer::InitMoc() if (this->GenTarget->GetPropertyAsBool("AUTOMOC_COMPILER_PREDEFINES") && (this->QtVersion >= IntegerVersion(5, 8))) { // Command - this->Makefile->GetDefExpandList("CMAKE_CXX_COMPILER_PREDEFINES_COMMAND", - this->Moc.PredefsCmd); + cmList::assign( + this->Moc.PredefsCmd, + this->Makefile->GetDefinition("CMAKE_CXX_COMPILER_PREDEFINES_COMMAND")); // Header if (!this->Moc.PredefsCmd.empty()) { this->ConfigFileNames(this->Moc.PredefsFile, diff --git a/Source/cmRuntimeDependencyArchive.cxx b/Source/cmRuntimeDependencyArchive.cxx index 4dfdfae..2fbf2fa 100644 --- a/Source/cmRuntimeDependencyArchive.cxx +++ b/Source/cmRuntimeDependencyArchive.cxx @@ -3,13 +3,21 @@ #include "cmRuntimeDependencyArchive.h" +#include <algorithm> +#include <sstream> +#include <string> +#include <utility> +#include <vector> + +#include <cm/memory> + #include "cmBinUtilsLinuxELFLinker.h" #include "cmBinUtilsMacOSMachOLinker.h" #include "cmBinUtilsWindowsPELinker.h" #include "cmExecutionStatus.h" +#include "cmList.h" #include "cmMakefile.h" #include "cmStateTypes.h" -#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #if defined(_WIN32) @@ -22,14 +30,6 @@ # include "cmVSSetupHelper.h" #endif -#include <algorithm> -#include <sstream> -#include <string> -#include <utility> -#include <vector> - -#include <cm/memory> - #if defined(_WIN32) static void AddVisualStudioPath(std::vector<std::string>& paths, const std::string& prefix, diff --git a/Source/cmStringAlgorithms.h b/Source/cmStringAlgorithms.h index 4ccbb8e..4a9840b 100644 --- a/Source/cmStringAlgorithms.h +++ b/Source/cmStringAlgorithms.h @@ -14,7 +14,6 @@ #include <cm/string_view> -#include "cmList.h" #include "cmRange.h" #include "cmValue.h" @@ -89,38 +88,6 @@ std::string cmJoin(cmStringRange const& rng, cm::string_view separator, /** Extract tokens that are separated by any of the characters in @a sep. */ std::vector<std::string> cmTokenize(cm::string_view str, cm::string_view sep); -/** - * Expand the ; separated string @a arg into multiple arguments. - * All found arguments are appended to @a argsOut. - */ -inline void cmExpandList(cm::string_view arg, - std::vector<std::string>& argsOut, - bool emptyArgs = false) -{ - cmList::append(arg, argsOut, - emptyArgs ? cmList::EmptyElements::Yes - : cmList::EmptyElements::No); -} -inline void cmExpandList(cmValue arg, std::vector<std::string>& argsOut, - bool emptyArgs = false) -{ - cmList::append(arg, argsOut, - emptyArgs ? cmList::EmptyElements::Yes - : cmList::EmptyElements::No); -} - -/** - * Expand out any arguments in the string range [@a first, @a last) that have - * ; separated strings into multiple arguments. All found arguments are - * appended to @a argsOut. - */ -template <class InputIt> -void cmExpandLists(InputIt first, InputIt last, - std::vector<std::string>& argsOut) -{ - cmList::append(first, last, argsOut); -} - /** Concatenate string pieces into a single string. */ std::string cmCatViews( std::initializer_list<std::pair<cm::string_view, std::string*>> views); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c156f69..0fbe430 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -397,6 +397,10 @@ TargetProperty const StaticTargetProperties[] = { { "MSVC_DEBUG_INFORMATION_FORMAT"_s, IC::CanCompileSources }, { "MSVC_RUNTIME_LIBRARY"_s, IC::CanCompileSources }, { "VS_JUST_MY_CODE_DEBUGGING"_s, IC::CanCompileSources }, + { "VS_DEBUGGER_COMMAND"_s, IC::ExecutableTarget }, + { "VS_DEBUGGER_COMMAND_ARGUMENTS"_s, IC::ExecutableTarget }, + { "VS_DEBUGGER_ENVIRONMENT"_s, IC::ExecutableTarget }, + { "VS_DEBUGGER_WORKING_DIRECTORY"_s, IC::ExecutableTarget }, // ---- OpenWatcom { "WATCOM_RUNTIME_LIBRARY"_s, IC::CanCompileSources }, // -- Language @@ -3031,11 +3035,11 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config, cmValue& loc, // Track the configuration-specific property suffix. suffix = cmStrCat('_', config_upper); - std::vector<std::string> mappedConfigs; + cmList mappedConfigs; { std::string mapProp = cmStrCat("MAP_IMPORTED_CONFIG_", config_upper); if (cmValue mapValue = this->GetProperty(mapProp)) { - cmExpandList(*mapValue, mappedConfigs, true); + mappedConfigs.assign(*mapValue, cmList::EmptyElements::Yes); } } @@ -3117,9 +3121,9 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config, cmValue& loc, // If we have not yet found it then the project is willing to try // any available configuration. if (!loc && !imp) { - std::vector<std::string> availableConfigs; + cmList availableConfigs; if (cmValue iconfigs = this->GetProperty("IMPORTED_CONFIGURATIONS")) { - cmExpandList(*iconfigs, availableConfigs); + availableConfigs.assign(*iconfigs); } for (auto aci = availableConfigs.begin(); !loc && !imp && aci != availableConfigs.end(); ++aci) { diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index ec6608d..7360bf5 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1094,10 +1094,10 @@ void cmVisualStudio10TargetGenerator::WritePackageReferences(Elem& e0) void cmVisualStudio10TargetGenerator::WriteDotNetReferences(Elem& e0) { - std::vector<std::string> references; + cmList references; if (cmValue vsDotNetReferences = this->GeneratorTarget->GetProperty("VS_DOTNET_REFERENCES")) { - cmExpandList(*vsDotNetReferences, references); + references.assign(*vsDotNetReferences); } cmPropertyMap const& props = this->GeneratorTarget->Target->GetProperties(); for (auto const& i : props.GetList()) { @@ -1114,7 +1114,7 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferences(Elem& e0) } if (!references.empty() || !this->DotNetHintReferences.empty()) { Elem e1(e0, "ItemGroup"); - for (std::string const& ri : references) { + for (auto const& ri : references) { // if the entry from VS_DOTNET_REFERENCES is an existing file, generate // a new hint-reference and name it from the filename if (cmsys::SystemTools::FileExists(ri, true)) { @@ -1369,20 +1369,20 @@ void cmVisualStudio10TargetGenerator::WriteTargetsFileReferences(Elem& e1) void cmVisualStudio10TargetGenerator::WriteWinRTReferences(Elem& e0) { - std::vector<std::string> references; + cmList references; if (cmValue vsWinRTReferences = this->GeneratorTarget->GetProperty("VS_WINRT_REFERENCES")) { - cmExpandList(*vsWinRTReferences, references); + references.assign(*vsWinRTReferences); } if (this->GlobalGenerator->TargetsWindowsPhone() && this->GlobalGenerator->GetSystemVersion() == "8.0" && references.empty()) { - references.push_back("platform.winmd"); + references.push_back(std::string{ "platform.winmd" }); } if (!references.empty()) { Elem e1(e0, "ItemGroup"); - for (std::string const& ri : references) { + for (auto const& ri : references) { Elem e2(e1, "Reference"); e2.Attribute("Include", ri); e2.Element("IsWinMDFile", "true"); @@ -4817,13 +4817,13 @@ void cmVisualStudio10TargetGenerator::WriteSinglePlatformExtension( void cmVisualStudio10TargetGenerator::WriteSDKReferences(Elem& e0) { - std::vector<std::string> sdkReferences; + cmList sdkReferences; std::unique_ptr<Elem> spe1; if (cmValue vsSDKReferences = this->GeneratorTarget->GetProperty("VS_SDK_REFERENCES")) { - cmExpandList(*vsSDKReferences, sdkReferences); + sdkReferences.assign(*vsSDKReferences); spe1 = cm::make_unique<Elem>(e0, "ItemGroup"); - for (std::string const& ri : sdkReferences) { + for (auto const& ri : sdkReferences) { Elem(*spe1, "SDKReference").Attribute("Include", ri); } } diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 623478e..0fd7461 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -3141,9 +3141,8 @@ int cmake::CheckBuildSystem() } // If any byproduct of makefile generation is missing we must re-run. - std::vector<std::string> products; - mf.GetDefExpandList("CMAKE_MAKEFILE_PRODUCTS", products); - for (std::string const& p : products) { + cmList products{ mf.GetDefinition("CMAKE_MAKEFILE_PRODUCTS") }; + for (auto const& p : products) { if (!(cmSystemTools::FileExists(p) || cmSystemTools::FileIsSymlink(p))) { if (verbose) { cmSystemTools::Stdout( @@ -3154,10 +3153,10 @@ int cmake::CheckBuildSystem() } // Get the set of dependencies and outputs. - std::vector<std::string> depends; - std::vector<std::string> outputs; - if (mf.GetDefExpandList("CMAKE_MAKEFILE_DEPENDS", depends)) { - mf.GetDefExpandList("CMAKE_MAKEFILE_OUTPUTS", outputs); + cmList depends{ mf.GetDefinition("CMAKE_MAKEFILE_DEPENDS") }; + cmList outputs; + if (!depends.empty()) { + outputs.assign(mf.GetDefinition("CMAKE_MAKEFILE_OUTPUTS")); } if (depends.empty() || outputs.empty()) { // Not enough information was provided to do the test. Just rerun. @@ -3433,19 +3432,18 @@ void cmake::IssueMessage(MessageType t, std::string const& text, std::vector<std::string> cmake::GetDebugConfigs() { - std::vector<std::string> configs; + cmList configs; if (cmValue config_list = this->State->GetGlobalProperty("DEBUG_CONFIGURATIONS")) { // Expand the specified list and convert to upper-case. - cmExpandList(*config_list, configs); - std::transform(configs.begin(), configs.end(), configs.begin(), - cmSystemTools::UpperCase); + configs.assign(*config_list); + configs.transform(cmList::TransformAction::TOUPPER); } // If no configurations were specified, use a default list. if (configs.empty()) { configs.emplace_back("DEBUG"); } - return configs; + return std::move(configs.data()); } int cmake::Build(int jobs, std::string dir, std::vector<std::string> targets, diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index f4d17f8..9929e85 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -559,8 +559,8 @@ struct CoCompileJob int cmcmd::HandleCoCompileCommands(std::vector<std::string> const& args) { std::vector<CoCompileJob> jobs; - std::string sourceFile; // store --source= - std::vector<std::string> launchers; // store --launcher= + std::string sourceFile; // store --source= + cmList launchers; // store --launcher= // Default is to run the original command found after -- if the option // does not need to do that, it should be specified here, currently only @@ -593,7 +593,7 @@ int cmcmd::HandleCoCompileCommands(std::vector<std::string> const& args) if (cmHasLiteralPrefix(arg, "--source=")) { sourceFile = arg.substr(9); } else if (cmHasLiteralPrefix(arg, "--launcher=")) { - cmExpandList(arg.substr(11), launchers, true); + launchers.append(arg.substr(11), cmList::EmptyElements::Yes); } else { // if it was not a co-compiler or --source/--launcher then error std::cerr << "__run_co_compile given unknown argument: " << arg diff --git a/Tests/CMakeLib/testList.cxx b/Tests/CMakeLib/testList.cxx index 7294be0..f6ec720 100644 --- a/Tests/CMakeLib/testList.cxx +++ b/Tests/CMakeLib/testList.cxx @@ -8,7 +8,7 @@ #include <utility> #include <vector> -#include <cm/string_view> +#include <cmext/string_view> #include "cmList.h" @@ -42,7 +42,7 @@ bool testConstructors() } { cmList list1{ "aa", "bb" }; - cmList list2("aa;bb"); + cmList list2("aa;bb"_s); if (list1.size() != 2 || list2.size() != 2 || list1 != list2) { result = false; @@ -174,7 +174,7 @@ bool testAssign() { cmList list{ "cc", "dd" }; - list = "aa;bb"; + list = "aa;bb"_s; if (list.size() != 2) { result = false; } @@ -195,7 +195,7 @@ bool testConversions() bool result = true; { - cmList list("a;b;c"); + cmList list("a;b;c"_s); std::string s = list.to_string(); if (s != "a;b;c") { @@ -203,7 +203,7 @@ bool testConversions() } } { - cmList list("a;b;c"); + cmList list("a;b;c"_s); std::vector<std::string> v = list; if (list.size() != 3 || v.size() != 3) { @@ -211,7 +211,7 @@ bool testConversions() } } { - cmList list("a;b;c"); + cmList list("a;b;c"_s); std::vector<std::string> v = std::move(list); // Microsoft compiler is not able to handle correctly the move semantics @@ -221,7 +221,7 @@ bool testConversions() } } { - cmList list("a;b;c"); + cmList list("a;b;c"_s); std::vector<std::string> v; // compiler is not able to select the cmList conversion operator @@ -247,20 +247,20 @@ bool testAccess() { cmList list{ "a", "b", "c" }; - if (list.at(1) != "b") { + if (list.get_item(1) != "b") { result = false; } } { cmList list{ "a", "b", "c" }; - if (list.at(-3) != "a") { + if (list.get_item(-3) != "a") { result = false; } } { try { cmList list{ "a", "b", "c" }; - if (list.at(4) != "a") { + if (list.get_item(4) != "a") { result = false; } } catch (std::out_of_range&) { @@ -269,7 +269,7 @@ bool testAccess() { try { cmList list{ "a", "b", "c" }; - if (list.at(-4) != "a") { + if (list.get_item(-4) != "a") { result = false; } } catch (std::out_of_range&) { @@ -342,7 +342,7 @@ bool testModifiers() { cmList list{ "1;2;3;4;5" }; - auto it = list.insert(list.begin() + 2, "6;7;8"); + auto it = list.insert(list.begin() + 2, "6;7;8"_s); if (list.size() != 8 || list.to_string() != "1;2;6;7;8;3;4;5") { result = false; } @@ -354,7 +354,7 @@ bool testModifiers() cmList list{ "1;2;3;4;5" }; auto it = - list.insert(list.begin() + 2, "6;7;8", cmList::ExpandElements::No); + list.insert(list.begin() + 2, "6;7;8"_s, cmList::ExpandElements::No); if (list.size() != 6 || list.to_string() != "1;2;6;7;8;3;4;5") { result = false; } @@ -479,7 +479,7 @@ bool testRemoveItems() bool result = true; { - cmList list("a;b;c;d;e;f;g;h"); + cmList list("a;b;c;d;e;f;g;h"_s); list.remove_items({ 1, 3, 5 }); @@ -488,7 +488,7 @@ bool testRemoveItems() } } { - cmList list("a;b;c;b;a;d;e;f"); + cmList list("a;b;c;b;a;d;e;f"_s); list.remove_items({ "a", "b", "h" }); @@ -497,7 +497,7 @@ bool testRemoveItems() } } { - cmList list("a;b;c;d;e;f;g;h"); + cmList list("a;b;c;d;e;f;g;h"_s); std::vector<cmList::index_type> remove{ 1, 3, 5 }; list.remove_items(remove.begin(), remove.end()); @@ -507,7 +507,7 @@ bool testRemoveItems() } } { - cmList list("a;b;c;b;a;d;e;f"); + cmList list("a;b;c;b;a;d;e;f"_s); std::vector<std::string> remove{ "b", "a", "h" }; list.remove_items(remove.begin(), remove.end()); @@ -529,7 +529,7 @@ bool testRemoveDuplicates() bool result = true; { - cmList list("b;c;b;a;a;c;b;a;c;b"); + cmList list("b;c;b;a;a;c;b;a;c;b"_s); list.remove_duplicates(); @@ -803,7 +803,7 @@ bool testStaticModifiers() { std::vector<std::string> v{ "a", "b", "c" }; - cmList::assign("d;e", v); + cmList::assign(v, "d;e"_s); if (v.size() != 2 || v[0] != "d" || v[1] != "e") { result = false; @@ -811,7 +811,7 @@ bool testStaticModifiers() } { std::vector<std::string> v{ "a", "b", "c" }; - cmList::append("d;;e", v); + cmList::append(v, "d;;e"_s); if (v.size() != 5 || v[3] != "d" || v[4] != "e") { result = false; @@ -819,7 +819,7 @@ bool testStaticModifiers() } { std::vector<std::string> v{ "a", "b", "c" }; - cmList::append("d;;e", v, cmList::EmptyElements::Yes); + cmList::append(v, "d;;e"_s, cmList::EmptyElements::Yes); if (v.size() != 6 || v[3] != "d" || !v[4].empty() || v[5] != "e") { result = false; @@ -827,7 +827,7 @@ bool testStaticModifiers() } { std::vector<std::string> v{ "a", "b", "c" }; - cmList::prepend("d;e", v); + cmList::prepend(v, "d;e"_s); if (v.size() != 5 || v[0] != "d" || v[1] != "e") { result = false; @@ -835,7 +835,7 @@ bool testStaticModifiers() } { std::vector<std::string> v{ "a", "b", "c" }; - cmList::prepend("d;;e", v, cmList::EmptyElements::Yes); + cmList::prepend(v, "d;;e"_s, cmList::EmptyElements::Yes); if (v.size() != 6 || v[0] != "d" || !v[1].empty() || v[2] != "e") { result = false; @@ -843,7 +843,7 @@ bool testStaticModifiers() } { std::string list{ "a;b;c" }; - cmList::append("d;e", list); + cmList::append(list, "d;e"_s); if (list != "a;b;c;d;e") { result = false; @@ -851,7 +851,7 @@ bool testStaticModifiers() } { std::string list; - cmList::append("d;e", list); + cmList::append(list, "d;e"_s); if (list != "d;e") { result = false; @@ -859,7 +859,7 @@ bool testStaticModifiers() } { std::string list{ "a;b;c" }; - cmList::append("", list); + cmList::append(list, ""); if (list != "a;b;c;") { result = false; @@ -868,7 +868,7 @@ bool testStaticModifiers() { std::string list{ "a;b;c" }; std::vector<std::string> v{ "d", "e" }; - cmList::append(v.begin(), v.end(), list); + cmList::append(list, v.begin(), v.end()); if (list != "a;b;c;d;e") { result = false; @@ -877,7 +877,7 @@ bool testStaticModifiers() { std::string list{ "a;b;c" }; std::vector<std::string> v; - cmList::append(v.begin(), v.end(), list); + cmList::append(list, v.begin(), v.end()); if (list != "a;b;c") { result = false; @@ -886,7 +886,7 @@ bool testStaticModifiers() { std::string list; std::vector<std::string> v{ "d", "e" }; - cmList::append(v.begin(), v.end(), list); + cmList::append(list, v.begin(), v.end()); if (list != "d;e") { result = false; @@ -894,7 +894,7 @@ bool testStaticModifiers() } { std::string list{ "a;b;c" }; - cmList::prepend("d;e", list); + cmList::prepend(list, "d;e"); if (list != "d;e;a;b;c") { result = false; @@ -902,7 +902,7 @@ bool testStaticModifiers() } { std::string list; - cmList::prepend("d;e", list); + cmList::prepend(list, "d;e"); if (list != "d;e") { result = false; @@ -910,7 +910,7 @@ bool testStaticModifiers() } { std::string list{ "a;b;c" }; - cmList::prepend("", list); + cmList::prepend(list, ""); if (list != ";a;b;c") { result = false; @@ -919,7 +919,7 @@ bool testStaticModifiers() { std::string list{ "a;b;c" }; std::vector<std::string> v{ "d", "e" }; - cmList::prepend(v.begin(), v.end(), list); + cmList::prepend(list, v.begin(), v.end()); if (list != "d;e;a;b;c") { result = false; @@ -928,7 +928,7 @@ bool testStaticModifiers() { std::string list{ "a;b;c" }; std::vector<std::string> v; - cmList::prepend(v.begin(), v.end(), list); + cmList::prepend(list, v.begin(), v.end()); if (list != "a;b;c") { result = false; @@ -937,7 +937,7 @@ bool testStaticModifiers() { std::string list; std::vector<std::string> v{ "d", "e" }; - cmList::prepend(v.begin(), v.end(), list); + cmList::prepend(list, v.begin(), v.end()); if (list != "d;e") { result = false; diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index e92d1c1..e3b5ec4 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -986,6 +986,30 @@ if(BUILD_TESTING) endif() endif() + # On Windows run the CPackInnoSetupGenerator test + if(WIN32 AND CMake_TEST_CPACK_INNOSETUP) + add_test(CPackInnoSetupGenerator ${CMAKE_CTEST_COMMAND} + -C \${CTEST_CONFIGURATION_TYPE} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/CPackInnoSetupGenerator" + "${CMake_BINARY_DIR}/Tests/CPackInnoSetupGenerator" + ${build_generator_args} + --build-project CPackInnoSetupGenerator + --build-options + --test-command ${CMAKE_CMAKE_COMMAND} + "-DCPackInnoSetupGenerator_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/CPackInnoSetupGenerator" + "-Dconfig=\${CTEST_CONFIGURATION_TYPE}" + -P "${CMake_SOURCE_DIR}/Tests/CPackInnoSetupGenerator/RunCPackVerifyResult.cmake") + + set_property(TEST CPackInnoSetupGenerator PROPERTY + ATTACHED_FILES_ON_FAIL + "${CMake_BINARY_DIR}/Tests/CPackInnoSetupGenerator/_CPack_Packages/win32/INNOSETUP/ISCCOutput.log") + + set_property(TEST CPackInnoSetupGenerator PROPERTY + ATTACHED_FILES + "${CMake_BINARY_DIR}/Tests/CPackInnoSetupGenerator/_CPack_Packages/win32/INNOSETUP/ISScript.iss") + endif() + # On Windows run the CPackNSISGenerator test # if the nsis is available if(WIN32 AND NSIS_MAKENSIS_EXECUTABLE) diff --git a/Tests/CPackInnoSetupGenerator/CMakeLists.txt b/Tests/CPackInnoSetupGenerator/CMakeLists.txt new file mode 100644 index 0000000..bca0ad6 --- /dev/null +++ b/Tests/CPackInnoSetupGenerator/CMakeLists.txt @@ -0,0 +1,55 @@ +cmake_minimum_required(VERSION 3.13) + +project(CPackInnoSetupGenerator VERSION 42.0 HOMEPAGE_URL "https://www.example.com") + +add_executable(hello main.c) +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/empty) + +install(TARGETS hello DESTINATION / COMPONENT application) +install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/empty DESTINATION / COMPONENT extras) +install(FILES my_bitmap.bmp DESTINATION awesome COMPONENT extras) +install(FILES my_file.txt DESTINATION / COMPONENT hidden_component) +install(FILES my_file.txt DESTINATION / COMPONENT hidden_component2) + +set(CPACK_GENERATOR "INNOSETUP") + +set(CPACK_PACKAGE_NAME "Hello, World!") # Test constant escape (like {cm:...}, see code documentation) +set(CPACK_PACKAGE_VENDOR "Sheldon Cooper") +set(CPACK_PACKAGE_INSTALL_DIRECTORY "hello_world") +set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "hello_world") +set(CPACK_PACKAGE_FILE_NAME "hello_world_setup") +set(CPACK_SYSTEM_NAME "win32") +set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/my_bitmap.bmp") +set(CPACK_VERBATIM_VARIABLES ON) +set(CPACK_PACKAGE_EXECUTABLES "hello" "Hello, World!") +set(CPACK_CREATE_DESKTOP_LINKS hello) + +set(CPACK_INNOSETUP_INSTALL_ROOT "{autopf}\\Sheldon Cooper") +set(CPACK_INNOSETUP_PROGRAM_MENU_FOLDER ".") +set(CPACK_INNOSETUP_IGNORE_LICENSE_PAGE ON) +set(CPACK_INNOSETUP_IGNORE_README_PAGE OFF) # Test if only readme page is shown +set(CPACK_INNOSETUP_SETUP_AppComments ON) # Test if CPACK_INNOSETUP_USE_CMAKE_BOOL_FORMAT works +set(CPACK_INNOSETUP_CUSTOM_INSTALL_INSTRUCTIONS "extras/empty" + "Name: \"{userdocs}\\empty\"\; Check: ReturnTrue\; Components: accessories\\extras") +set(CPACK_INNOSETUP_MENU_LINKS "https://www.example.com" "Web" + "my_file.txt" "Text") +set(CPACK_INNOSETUP_RUN_EXECUTABLES hello) +set(CPACK_INNOSETUP_CREATE_UNINSTALL_LINK ON) +# Test if this macro is available in the code file below containing the check function +set(CPACK_INNOSETUP_DEFINE_PascalMacro "end;") +set(CPACK_INNOSETUP_CODE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/Code.pas") +set(CPACK_INNOSETUP_EXECUTABLE "ISCC.exe") + +include(CPackComponent) + +cpack_add_install_type(basic DISPLAY_NAME "Basic installation") +cpack_add_install_type(full DISPLAY_NAME "\"Large\" installation") # Test double quote syntax +cpack_add_component_group(accessories DISPLAY_NAME "Accessories") + +cpack_add_component(application DISPLAY_NAME "Application" INSTALL_TYPES basic full REQUIRED) +cpack_add_component(extras DISPLAY_NAME "Additional components" INSTALL_TYPES full GROUP accessories) +cpack_add_component(hidden_component HIDDEN) +cpack_add_component(hidden_component2 HIDDEN DISABLED) +set(CPACK_INNOSETUP_extras_INSTALL_DIRECTORY "{userdocs}") + +include(CPack) diff --git a/Tests/CPackInnoSetupGenerator/Code.pas b/Tests/CPackInnoSetupGenerator/Code.pas new file mode 100644 index 0000000..d96d82f --- /dev/null +++ b/Tests/CPackInnoSetupGenerator/Code.pas @@ -0,0 +1,4 @@ +function ReturnTrue(): Boolean; +begin + Result := true; +{#PascalMacro} diff --git a/Tests/CPackInnoSetupGenerator/RunCPackVerifyResult.cmake b/Tests/CPackInnoSetupGenerator/RunCPackVerifyResult.cmake new file mode 100644 index 0000000..72a26ee --- /dev/null +++ b/Tests/CPackInnoSetupGenerator/RunCPackVerifyResult.cmake @@ -0,0 +1,136 @@ +message(STATUS "=============================================================") +message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)") +message(STATUS "") + +if(NOT CPackInnoSetupGenerator_BINARY_DIR) + message(FATAL_ERROR "CPackInnoSetupGenerator_BINARY_DIR not set") +endif() + +message(STATUS "CMAKE_COMMAND: ${CMAKE_COMMAND}") +message(STATUS "CMAKE_CPACK_COMMAND: ${CMAKE_CPACK_COMMAND}") +message(STATUS "CPackInnoSetupGenerator_BINARY_DIR: ${CPackInnoSetupGenerator_BINARY_DIR}") + +if(config) + set(_C_config -C ${config}) +endif() + +execute_process(COMMAND "${CMAKE_CPACK_COMMAND}" + ${_C_config} + RESULT_VARIABLE CPack_result + OUTPUT_VARIABLE CPack_output + ERROR_VARIABLE CPack_output + WORKING_DIRECTORY "${CPackInnoSetupGenerator_BINARY_DIR}") + +if(CPack_result) + message(FATAL_ERROR "CPack execution went wrong!, Output: ${CPack_output}") +else () + message(STATUS "Output: ${CPack_output}") +endif() + +file(GLOB project_file "${CPackInnoSetupGenerator_BINARY_DIR}/_CPack_Packages/win32/INNOSETUP/ISScript.iss") +file(GLOB installer_file "${CPackInnoSetupGenerator_BINARY_DIR}/_CPack_Packages/win32/INNOSETUP/hello_world_setup.exe") + +message(STATUS "Project file: '${project_file}'") +message(STATUS "Installer file: '${installer_file}'") + +if(NOT project_file) + message(FATAL_ERROR "Project file does not exist") +endif() + +if(NOT installer_file) + message(FATAL_ERROR "Installer file does not exist") +endif() + +# Test if the correct registry key is set +file(STRINGS "${project_file}" results REGEX "^AppId=hello_world$") +if(results STREQUAL "") + message(FATAL_ERROR "CPACK_PACKAGE_INSTALL_REGISTRY_KEY doesn't match AppId") +endif() + +# Test if only readme page is shown +file(STRINGS "${project_file}" results REGEX "^LicenseFile=") +file(STRINGS "${project_file}" results2 REGEX "^InfoBeforeFile=") +if(NOT results STREQUAL "" OR results2 STREQUAL "") + message(FATAL_ERROR "Erroneous output with license and readme files") +endif() + +# Test if classic style is used by default +file(STRINGS "${project_file}" results REGEX "compiler:SetupClassicIcon\\.ico") +file(STRINGS "${project_file}" results2 REGEX "compiler:WizClassicImage\\.bmp") +if(results STREQUAL "" OR results2 STREQUAL "") + message(FATAL_ERROR "Images of classic style not used") +endif() + +# Test if the top-level start menu folder is used +file(STRINGS "${project_file}" results REGEX "{autoprograms}") +file(STRINGS "${project_file}" results2 REGEX "{group}") +if(results STREQUAL "" OR NOT results2 STREQUAL "") + message(FATAL_ERROR "Top-level start menu folder not used") +endif() + +# Test CPACK_INNOSETUP_USE_CMAKE_BOOL_FORMAT +file(STRINGS "${project_file}" results REGEX "^AppComments=yes$") +if(results STREQUAL "") + message(FATAL_ERROR "CPACK_INNOSETUP_USE_CMAKE_BOOL_FORMAT doesn't convert booleans") +endif() + +# Test the custom installation rule +file(STRINGS "${project_file}" results REGEX "^Name: \"{userdocs}\\\\empty\"; Check: ReturnTrue; Components: accessories\\\\extras$") +if(results STREQUAL "") + message(FATAL_ERROR "Custom installation rule not found or incomplete") +endif() + +# Test if an uninstall shortcut has been created +file(STRINGS "${project_file}" results REGEX "{uninstallexe}") +if(results STREQUAL "") + message(FATAL_ERROR "No uninstall shortcut created") +endif() + +# Test CPACK_INNOSETUP_<compName>_INSTALL_DIRECTORY +file(STRINGS "${project_file}" results REGEX "{app}.*Components: accessories\\\\extras") +if(NOT results STREQUAL "") + message(FATAL_ERROR "Component not in custom install directory") +endif() + +# Test if component names are nested correctly +file(STRINGS "${project_file}" results REGEX "Components:.* extras") +if(NOT results STREQUAL "") + message(FATAL_ERROR "Component names must contain their parent groups according to the documentation") +endif() + +# Test if custom installation type exists +file(STRINGS "${project_file}" results REGEX "Flags: .*iscustom") +if(results STREQUAL "") + message(FATAL_ERROR "Custom installation type doesn't exist") +endif() + +# Test if hidden components are processed but not displayed +file(STRINGS "${project_file}" results REGEX "Source:.+hidden_component\\\\my_file\\.txt") +file(STRINGS "${project_file}" results2 REGEX "Name: \"hidden_component\"") +if(results STREQUAL "" OR NOT results2 STREQUAL "") + message(FATAL_ERROR "Hidden component displayed or one of its files ignored") +endif() + +# Test if disabled and hidden components are ignored at all +file(STRINGS "${project_file}" results REGEX "Source:.+hidden_component2\\\\my_file\\.txt") +if(NOT results STREQUAL "") + message(FATAL_ERROR "Disabled and hidden component not ignored") +endif() + +# Test if required components ignore their installation types +file(STRINGS "${project_file}" results REGEX "Types: (basic|full|custom|basic full|full basic|basic custom|full custom); Flags: fixed") +if(NOT results STREQUAL "") + message(FATAL_ERROR "Required components don't ignore their installation types") +endif() + +# Test constant escape (should contain Hello%2c World!) +file(STRINGS "${project_file}" results REGEX "Hello%2c World!") +if(results STREQUAL "") + message(FATAL_ERROR "The comma character isn't escaped to %2c") +endif() + +# Test double quote syntax +file(STRINGS "${project_file}" results REGEX "\"\"Large\"\"") +if(results STREQUAL "") + message(FATAL_ERROR "The quote character isn't escaped correctly") +endif() diff --git a/Tests/CPackInnoSetupGenerator/main.c b/Tests/CPackInnoSetupGenerator/main.c new file mode 100644 index 0000000..413899c --- /dev/null +++ b/Tests/CPackInnoSetupGenerator/main.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main() +{ + printf("Hello, World!\n"); + return 42; +} diff --git a/Tests/CPackInnoSetupGenerator/my_bitmap.bmp b/Tests/CPackInnoSetupGenerator/my_bitmap.bmp Binary files differnew file mode 100644 index 0000000..d0e562f --- /dev/null +++ b/Tests/CPackInnoSetupGenerator/my_bitmap.bmp diff --git a/Tests/CPackInnoSetupGenerator/my_file.txt b/Tests/CPackInnoSetupGenerator/my_file.txt new file mode 100644 index 0000000..8ab686e --- /dev/null +++ b/Tests/CPackInnoSetupGenerator/my_file.txt @@ -0,0 +1 @@ +Hello, World! diff --git a/Tests/CompileFeatures/default_dialect.c b/Tests/CompileFeatures/default_dialect.c index b990e53..c696c83 100644 --- a/Tests/CompileFeatures/default_dialect.c +++ b/Tests/CompileFeatures/default_dialect.c @@ -20,7 +20,8 @@ # error Buildsystem error # endif # if defined(__STDC_VERSION__) && \ - !(defined(__SUNPRO_C) && __STDC_VERSION__ == 199409L) + !(__STDC_VERSION__ == 199409L && \ + (defined(__INTEL_COMPILER) || defined(__SUNPRO_C))) # error Unexpected __STDC_VERSION__ definition # endif #endif diff --git a/Tests/FindX11/Test/CMakeLists.txt b/Tests/FindX11/Test/CMakeLists.txt index e39ffb1..3312f6f 100644 --- a/Tests/FindX11/Test/CMakeLists.txt +++ b/Tests/FindX11/Test/CMakeLists.txt @@ -32,16 +32,38 @@ test_x11_component(x11_components Xau) test_x11_component(x11_components Xaw) test_x11_component(x11_components xcb) test_x11_component(x11_components X11_xcb) +test_x11_component(x11_components xcb_composite) test_x11_component(x11_components xcb_cursor) +test_x11_component(x11_components xcb_damage) +test_x11_component(x11_components xcb_dpms) +test_x11_component(x11_components xcb_dri2) +test_x11_component(x11_components xcb_dri3) +test_x11_component(x11_components xcb_errors) +test_x11_component(x11_components xcb_ewmh) +test_x11_component(x11_components xcb_glx) test_x11_component(x11_components xcb_icccm) +test_x11_component(x11_components xcb_image) +test_x11_component(x11_components xcb_keysyms) +test_x11_component(x11_components xcb_present) test_x11_component(x11_components xcb_randr) +test_x11_component(x11_components xcb_record) +test_x11_component(x11_components xcb_render) +test_x11_component(x11_components xcb_render_util) +test_x11_component(x11_components xcb_res) +test_x11_component(x11_components xcb_screensaver) test_x11_component(x11_components xcb_shape) +test_x11_component(x11_components xcb_shm) +test_x11_component(x11_components xcb_sync) test_x11_component(x11_components xcb_util) +test_x11_component(x11_components xcb_xf86dri) test_x11_component(x11_components xcb_xfixes) +test_x11_component(x11_components xcb_xinerama) +test_x11_component(x11_components xcb_xinput) +test_x11_component(x11_components xcb_xkb) test_x11_component(x11_components xcb_xrm) test_x11_component(x11_components xcb_xtest) -test_x11_component(x11_components xcb_keysyms) -test_x11_component(x11_components xcb_xkb) +test_x11_component(x11_components xcb_xvmc) +test_x11_component(x11_components xcb_xv) test_x11_component(x11_components Xcomposite) test_x11_component(x11_components Xdamage) test_x11_component(x11_components Xdmcp) @@ -79,13 +101,38 @@ foreach(lib Xaw xcb X11_xcb + xcb_composite xcb_cursor + xcb_damage + xcb_dpms + xcb_dri2 + xcb_dri3 + xcb_errors + xcb_ewmh + xcb_glx xcb_icccm + xcb_image + xcb_keysyms + xcb_present xcb_randr + xcb_record + xcb_render + xcb_render_util + xcb_res + xcb_screensaver xcb_shape + xcb_shm + xcb_sync xcb_util + xcb_xf86dri xcb_xfixes + xcb_xinerama + xcb_xinput + xcb_xkb xcb_xrm + xcb_xtest + xcb_xvmc + xcb_xv Xcomposite Xdamage Xdmcp diff --git a/Tests/FindX11/Test/main.c b/Tests/FindX11/Test/main.c index 5240de0..2542145 100644 --- a/Tests/FindX11/Test/main.c +++ b/Tests/FindX11/Test/main.c @@ -326,7 +326,7 @@ static void test_Xaw(void) #endif -#ifdef HAVE_xcb +#ifdef HAVE_X11_xcb # include <xcb/xcb.h> static void test_xcb(void) @@ -336,24 +336,216 @@ static void test_xcb(void) xcb_disconnect(connection); } -# ifdef HAVE_xcb_cursor -# include <xcb/xcb_cursor.h> +#endif + +#ifdef HAVE_X11_xcb_composite +# include <xcb/composite.h> +# include <xcb/xcb.h> + +static void test_xcb_composite(void) +{ + xcb_connection_t* connection = xcb_connect(NULL, NULL); + xcb_composite_query_version(connection, 0, 0); + xcb_disconnect(connection); +} + +#endif + +#ifdef HAVE_X11_xcb_cursor +# include <xcb/xcb.h> +# include <xcb/xcb_cursor.h> static void test_xcb_cursor(void) { int screen_nbr; xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr); - xcb_screen_t* screen = xcb_aux_get_screen(conn, screen_nbr); + xcb_screen_iterator_t screens = + xcb_setup_roots_iterator(xcb_get_setup(connection)); xcb_cursor_context_t* ctx; - xcb_cursor_context_new(connection, screen, &ctx); + xcb_cursor_context_new(connection, screens.data, &ctx); xcb_cursor_context_free(ctx); xcb_disconnect(connection); } -# endif +#endif -# ifdef HAVE_xcb_randr -# include <xcb/randr.h> +#ifdef HAVE_X11_xcb_damage +# include <xcb/damage.h> +# include <xcb/xcb.h> + +static void test_xcb_damage(void) +{ + int screen_nbr; + xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr); + xcb_damage_query_version_cookie_t cookie = + xcb_damage_query_version(connection, 0, 0); + xcb_disconnect(connection); +} + +#endif + +#ifdef HAVE_X11_xcb_dpms +# include <xcb/dpms.h> +# include <xcb/xcb.h> + +static void test_xcb_dpms(void) +{ + int screen_nbr; + xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr); + xcb_dpms_get_version_cookie_t cookie = + xcb_dpms_get_version(connection, 0, 0); + xcb_disconnect(connection); +} + +#endif + +#ifdef HAVE_X11_xcb_dri2 +# include <xcb/dri2.h> +# include <xcb/xcb.h> + +static void test_xcb_dri2(void) +{ + int screen_nbr; + xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr); + xcb_dri2_query_version_cookie_t cookie = + xcb_dri2_query_version(connection, 0, 0); + xcb_disconnect(connection); +} + +#endif + +#ifdef HAVE_X11_xcb_dri3 +# include <xcb/dri3.h> +# include <xcb/xcb.h> + +static void test_xcb_dri3(void) +{ + int screen_nbr; + xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr); + xcb_dri3_query_version_cookie_t cookie = + xcb_dri3_query_version(connection, 0, 0); + xcb_disconnect(connection); +} + +#endif + +#ifdef HAVE_X11_xcb_errors +# include <xcb/xcb.h> +# include <xcb/xcb_errors.h> + +static void test_xcb_errors(void) +{ + int screen_nbr; + xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr); + xcb_errors_context_t* context; + xcb_errors_context_new(connection, &context); + xcb_errors_context_free(context); + xcb_disconnect(connection); +} + +#endif + +#ifdef HAVE_X11_xcb_ewmh +# include <xcb/xcb.h> +# include <xcb/xcb_ewmh.h> + +static void test_xcb_ewmh(void) +{ + int screen_nbr; + xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr); + xcb_ewmh_connection_t ewmh_connection; + xcb_intern_atom_cookie_t* cookie = + xcb_ewmh_init_atoms(connection, &ewmh_connection); + xcb_ewmh_init_atoms_replies(&ewmh_connection, cookie, NULL); + xcb_ewmh_connection_wipe(&ewmh_connection); + xcb_disconnect(connection); +} + +#endif + +#ifdef HAVE_X11_xcb_glx +# include <xcb/glx.h> +# include <xcb/xcb.h> + +static void test_xcb_glx(void) +{ + int screen_nbr; + xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr); + xcb_glx_query_version_cookie_t cookie = + xcb_glx_query_version(connection, 0, 0); + xcb_disconnect(connection); +} + +#endif + +#ifdef HAVE_X11_xcb_icccm +# include <xcb/xcb.h> +# include <xcb/xcb_icccm.h> + +static void test_xcb_icccm(void) +{ + int screen_nbr; + xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr); + xcb_window_t root = + xcb_setup_roots_iterator(xcb_get_setup(connection)).data->root; + xcb_get_property_cookie_t cookie = xcb_icccm_get_wm_name(connection, root); + xcb_icccm_get_text_property_reply_t reply; + xcb_icccm_get_wm_name_reply(connection, cookie, &reply, NULL); + xcb_disconnect(connection); +} + +#endif + +#ifdef HAVE_X11_xcb_image +# include <xcb/xcb.h> +# include <xcb/xcb_image.h> + +static void test_xcb_image(void) +{ + int screen_nbr; + xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr); + // xcb_image is too convoluted/undocumented to make an + // actually working example, apologies :) + xcb_image_create(0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, 0, 0); + xcb_disconnect(connection); +} + +#endif + +#ifdef HAVE_X11_xcb_keysyms +# include <xcb/xcb.h> +# include <xcb/xcb_keysyms.h> + +static void test_xcb_keysyms(void) +{ + int screen_nbr; + xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr); + xcb_key_symbols_t* symbols = xcb_key_symbols_alloc(connection); + if (symbols != NULL) + xcb_key_symbols_free(symbols); + xcb_disconnect(connection); +} + +#endif + +#ifdef HAVE_X11_xcb_present +# include <xcb/present.h> +# include <xcb/xcb.h> + +static void test_xcb_present(void) +{ + int screen_nbr; + xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr); + xcb_present_query_version_cookie_t cookie = + xcb_present_query_version(connection, 0, 0); + xcb_disconnect(connection); +} + +#endif + +#ifdef HAVE_X11_xcb_randr +# include <xcb/randr.h> +# include <xcb/xcb.h> static void test_xcb_randr(void) { @@ -364,10 +556,86 @@ static void test_xcb_randr(void) xcb_disconnect(connection); } -# endif +#endif + +#ifdef HAVE_X11_xcb_record +# include <xcb/record.h> +# include <xcb/xcb.h> + +static void test_xcb_record(void) +{ + int screen_nbr; + xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr); + xcb_record_query_version_cookie_t cookie = + xcb_record_query_version(connection, 0, 0); + xcb_disconnect(connection); +} -# ifdef HAVE_xcb_shape -# include <xcb/shape.h> +#endif + +#ifdef HAVE_X11_xcb_render +# include <xcb/render.h> +# include <xcb/xcb.h> + +static void test_xcb_render(void) +{ + int screen_nbr; + xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr); + xcb_render_query_version_cookie_t cookie = + xcb_render_query_version(connection, 0, 0); + xcb_disconnect(connection); +} + +#endif + +#ifdef HAVE_X11_xcb_render_util +# include <xcb/xcb.h> +# include <xcb/xcb_renderutil.h> + +static void test_xcb_render_util(void) +{ + int screen_nbr; + xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr); + const xcb_render_query_version_reply_t* cookie = + xcb_render_util_query_version(connection); + xcb_disconnect(connection); +} + +#endif + +#ifdef HAVE_X11_xcb_res +# include <xcb/res.h> +# include <xcb/xcb.h> + +static void test_xcb_res(void) +{ + int screen_nbr; + xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr); + xcb_res_query_version_cookie_t cookie = + xcb_res_query_version(connection, 0, 0); + xcb_disconnect(connection); +} + +#endif + +#ifdef HAVE_X11_xcb_screensaver +# include <xcb/screensaver.h> +# include <xcb/xcb.h> + +static void test_xcb_screensaver(void) +{ + int screen_nbr; + xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr); + xcb_screensaver_query_version_cookie_t cookie = + xcb_screensaver_query_version(connection, 0, 0); + xcb_disconnect(connection); +} + +#endif + +#ifdef HAVE_X11_xcb_shape +# include <xcb/shape.h> +# include <xcb/xcb.h> static void test_xcb_shape(void) { @@ -378,10 +646,39 @@ static void test_xcb_shape(void) xcb_disconnect(connection); } -# endif +#endif + +#ifdef HAVE_X11_xcb_shm +# include <xcb/shm.h> +# include <xcb/xcb.h> + +static void test_xcb_shm(void) +{ + int screen_nbr; + xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr); + xcb_shm_query_version_cookie_t cookie = xcb_shm_query_version(connection); + xcb_disconnect(connection); +} + +#endif + +#ifdef HAVE_X11_xcb_sync +# include <xcb/sync.h> +# include <xcb/xcb.h> + +static void test_xcb_sync(void) +{ + int screen_nbr; + xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr); + xcb_sync_initialize_cookie_t cookie = xcb_sync_initialize(connection, 0, 0); + xcb_disconnect(connection); +} + +#endif -# ifdef HAVE_xcb_util -# include <xcb/xcb_aux.h> +#ifdef HAVE_X11_xcb_util +# include <xcb/xcb.h> +# include <xcb/xcb_aux.h> static void test_xcb_util(void) { @@ -391,10 +688,26 @@ static void test_xcb_util(void) xcb_disconnect(connection); } -# endif +#endif + +#ifdef HAVE_X11_xcb_xf86dri +# include <xcb/xcb.h> +# include <xcb/xf86dri.h> + +static void test_xcb_xf86dri(void) +{ + int screen_nbr; + xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr); + xcb_xf86dri_query_version_cookie_t cookie = + xcb_xf86dri_query_version(connection); + xcb_disconnect(connection); +} + +#endif -# ifdef HAVE_xcb_xfixes -# include <xcb/xcb_xfixes.h> +#ifdef HAVE_X11_xcb_xfixes +# include <xcb/xcb.h> +# include <xcb/xfixes.h> static void test_xcb_xfixes(void) { @@ -404,10 +717,56 @@ static void test_xcb_xfixes(void) xcb_disconnect(connection); } -# endif +#endif + +#ifdef HAVE_X11_xcb_xinerama +# include <xcb/xcb.h> +# include <xcb/xinerama.h> + +static void test_xcb_xinerama(void) +{ + int screen_nbr; + xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr); + xcb_xinerama_query_version_cookie_t cookie = + xcb_xinerama_query_version(connection, 0, 0); + xcb_disconnect(connection); +} + +#endif + +#ifdef HAVE_X11_xcb_xinput +# include <xcb/xcb.h> +# include <xcb/xinput.h> + +static void test_xcb_xinput(void) +{ + int screen_nbr; + xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr); + xcb_input_xi_query_version_cookie_t cookie = + xcb_input_xi_query_version(connection, 0, 0); + xcb_disconnect(connection); +} + +#endif + +#ifdef HAVE_X11_xcb_xkb +# include <xcb/xcb.h> +# include <xcb/xkb.h> + +static void test_xcb_xkb(void) +{ + int screen_nbr; + xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr); + xcb_xkb_use_extension_cookie_t cookie = + xcb_xkb_use_extension(connection, 0, 0); + xcb_disconnect(connection); +} + +#endif -# ifdef HAVE_xcb_xrm -# include <xcb/xcb_xrm.h> +#ifdef HAVE_X11_xcb_xrm +# include <xcb/xcb.h> +# include <xcb/xcb_xrm.h> static void test_xcb_xrm(void) { @@ -418,10 +777,11 @@ static void test_xcb_xrm(void) xcb_disconnect(connection); } -# endif +#endif -# ifdef HAVE_xcb_xtest -# include <xcb/xtest.h> +#ifdef HAVE_X11_xcb_xtest +# include <xcb/xcb.h> +# include <xcb/xtest.h> static void test_xcb_xtest(void) { @@ -431,22 +791,33 @@ static void test_xcb_xtest(void) xcb_disconnect(connection); } -# endif +#endif -# ifdef HAVE_xcb_keysyms -# include <xcb/xcb_keysyms.h> +#ifdef HAVE_X11_xcb_xvmc +# include <xcb/xcb.h> +# include <xcb/xvmc.h> -static void test_xcb_keysyms(void) +static void test_xcb_xvmc(void) { int screen_nbr; xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr); - xcb_key_symbols_t* symbols = xcb_key_symbols_alloc(connection); - if (symbols != NULL) - xcb_key_symbols_free(symbols); + xcb_xvmc_query_version_cookie_t cookie = xcb_xvmc_query_version(connection); xcb_disconnect(connection); } -# endif +#endif + +#ifdef HAVE_X11_xcb_xv +# include <xcb/xcb.h> +# include <xcb/xv.h> + +static void test_xcb_xv(void) +{ + int screen_nbr; + xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr); + xcb_xv_query_extension_cookie_t cookie = xcb_xv_query_extension(connection); + xcb_disconnect(connection); +} #endif @@ -537,28 +908,105 @@ int main(int argc, char* argv[]) #ifdef HAVE_X11_Xaw test_Xaw, #endif -#ifdef HAVE_xcb +#ifdef HAVE_X11_xcb test_xcb, #endif -#ifdef HAVE_xcb_cursor +#ifdef HAVE_X11_xcb_composite + test_xcb_composite, +#endif +#ifdef HAVE_X11_xcb_cursor test_xcb_cursor, #endif -#ifdef HAVE_xcb_randr +#ifdef HAVE_X11_xcb_damage + test_xcb_damage, +#endif +#ifdef HAVE_X11_xcb_dpms + test_xcb_dpms, +#endif +#ifdef HAVE_X11_xcb_dri2 + test_xcb_dri2, +#endif +#ifdef HAVE_X11_xcb_dri3 + test_xcb_dri3, +#endif +#ifdef HAVE_X11_xcb_errors + test_xcb_errors, +#endif +#ifdef HAVE_X11_xcb_ewmh + test_xcb_ewmh, +#endif +#ifdef HAVE_X11_xcb_glx + test_xcb_glx, +#endif +#ifdef HAVE_X11_xcb_icccm + test_xcb_icccm, +#endif +#ifdef HAVE_X11_xcb_image + test_xcb_image, +#endif +#ifdef HAVE_X11_xcb_keysyms + test_xcb_keysyms, +#endif +#ifdef HAVE_X11_xcb_present + test_xcb_present, +#endif +#ifdef HAVE_X11_xcb_randr test_xcb_randr, #endif -#ifdef HAVE_xcb_shape +#ifdef HAVE_X11_xcb_record + test_xcb_record, +#endif +#ifdef HAVE_X11_xcb_render + test_xcb_render, +#endif +#ifdef HAVE_X11_xcb_render_util + test_xcb_render_util, +#endif +#ifdef HAVE_X11_xcb_res + test_xcb_res, +#endif +#ifdef HAVE_X11_xcb_screensaver + test_xcb_screensaver, +#endif +#ifdef HAVE_X11_xcb_shape test_xcb_shape, #endif -#ifdef HAVE_xcb_util +#ifdef HAVE_X11_xcb_shm + test_xcb_shm, +#endif +#ifdef HAVE_X11_xcb_sync + test_xcb_sync, +#endif +#ifdef HAVE_X11_xcb_util test_xcb_util, #endif -#ifdef HAVE_xcb_xfixes +#ifdef HAVE_X11_xcb_xf86dri + test_xcb_xf86dri, +#endif +#ifdef HAVE_X11_xcb_xfixes test_xcb_xfixes, #endif -#ifdef HAVE_xcb_xrm +#ifdef HAVE_X11_xcb_xinerama + test_xcb_xinerama, +#endif +#ifdef HAVE_X11_xcb_xinput + test_xcb_xinput, +#endif +#ifdef HAVE_X11_xcb_xkb + test_xcb_xkb, +#endif +#ifdef HAVE_X11_xcb_xrm test_xcb_xrm, #endif - +#ifdef HAVE_X11_xcb_xtest + test_xcb_xtest, +#endif +#ifdef HAVE_X11_xcb_xvmc + test_xcb_xvmc, +#endif +#ifdef HAVE_X11_xcb_xv + test_xcb_xv, +#endif NULL, }; @@ -567,5 +1015,6 @@ int main(int argc, char* argv[]) // always 1 in the test harness which always returns the sentinel at the end // of the array. The array logic is there to ensure that the contents of // `fptrs` is not optimized out. +#pragma GCC diagnostic ignored "-Wpointer-to-int-cast" return (int)fptrs[(sizeof(fptrs) / sizeof(*fptrs)) - argc]; } diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index 5e91e99..18dde94 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -177,7 +177,7 @@ function(run_cmake test) "|Your license to use PGI[^\n]*expired" "|Please obtain a new version at" "|contact PGI Sales at" - "|icp?c: remark #10441: The Intel\\(R\\) C\\+\\+ Compiler Classic \\(ICC\\) is deprecated" + "|ic(p?c|l): remark #10441: The Intel\\(R\\) C\\+\\+ Compiler Classic \\(ICC\\) is deprecated" "|[^\n]*install_name_tool: warning: changes being made to the file will invalidate the code signature in:" "|[^\n]*xcodebuild[^\n]*DVTCoreDeviceEnabledState: DVTCoreDeviceEnabledState_Disabled set via user default" |